带参数的.htaccess重写规则

时间:2014-06-30 13:51:03

标签: regex apache .htaccess mod-rewrite

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

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

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

我想将包含option = com_letflat的所有网址重写到域的根目录,即http://www.example.com

我尝试过几十种不同的东西,但似乎都没有。 我已经达到了这个目标:

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

但它不起作用。

由于

1 个答案:

答案 0 :(得分:1)

您可以使用此规则:

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

请确保这是.htaccess中的第一条规则

相关问题