【问题标题】:htacces rule with url variable to external url带有 url 变量的 htaccess 规则到外部 url
【发布时间】:2020-08-19 18:40:55
【问题描述】:

我有以下 htaccess 规则:

RewriteRule ^whatsapp$ https://web.whatsapp.com [L,NC]

结果:

If I call www.mydomain.de/whatsapp -> I will redirect to https://web.whatsapp.com

现在我想意识到这种情况:

I call www.mydomain.de/whatsapp=1234567 -> I will redirect to https://web.whatsapp.com/send?phone=1234567

有人可以帮助我吗? 谢谢!

【问题讨论】:

    标签: regex apache .htaccess mod-rewrite


    【解决方案1】:

    您可以使用 2 条不同的规则:

    RewriteRule ^whatsapp/?$ https://web.whatsapp.com [L,NC,R=302]
    
    RewriteRule ^whatsapp=([\w-]+)/?$ https://web.whatsapp.com/send?phone=$1 [L,NC,R=302,QSA]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-11-10
      • 1970-01-01
      • 2023-03-29
      • 1970-01-01
      • 2012-06-12
      • 2017-08-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多