根据查询字符串重写规则

时间:2013-05-14 08:24:54

标签: .htaccess joomla

我正在尝试重定向到具有特定查询字符串的基本网址(www.example.com)请求(optioncom_estateagent时)。

我尝试了以下语法:

RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} ^option=com_estateagent$
RewriteRule .* index.php [R=301, L]

但它被忽略了 有什么建议吗?

修改
我想改变的网址是这样的:
http://www.example.com/subdirectory/index.php?option=com_estateagent...

2 个答案:

答案 0 :(得分:0)

我认为你不需要RewriteCond指令,不会有这样的工作吗?

RewriteRule ^/.*option=com_estateagent /index.php[R=301,L]

答案 1 :(得分:0)

这有效

RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} option=com_estateagent
RewriteRule .* subdirectory/index.php? [R=301, L]

注意?之后的index.php。如果要在重定向上删除查询参数,这很重要。