【问题标题】:.htaccess rewrite rule with parameters.htaccess 带参数的重写规则
【发布时间】:2014-06-30 13:51:02
【问题描述】:

我有很多以下格式的网址。

index.php?option=com_letflat&task=view&id=42

index.php?option=com_letflat&task=view&task=ajaxmap

我想将所有包含option=com_letflat的url重写为域的根,即http://www.example.com

我尝试了几十种不同的方法,但似乎都没有奏效。 我已经做到了:

RewriteCond %{QUERY_STRING} (^|&)option=com_letflat [NC]
RewriteRule ^index.php(.*)  http://www.example.com [R=301,L]

但它不起作用。

谢谢

【问题讨论】:

    标签: regex apache .htaccess mod-rewrite


    【解决方案1】:

    你可以使用这条规则:

    RewriteEngine On
    RewriteCond %{QUERY_STRING} (^|&)option=com_letflat(&|$) [NC]
    RewriteRule ^index\.php /? [R=301,L]
    

    只要确保这是您的 .htaccess 中的第一条规则

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-11-10
      • 1970-01-01
      • 2016-12-14
      • 1970-01-01
      • 1970-01-01
      • 2018-02-03
      • 2013-12-26
      • 2023-04-02
      相关资源
      最近更新 更多