[英]HTACCESS 301 redirect URL with query string with no request URI
I have a site that has a bunch of URLs indexed in Google that look like this - 我有一个网站,其中有许多在Google中建立索引的网址,看起来像这样-
http://www.domain-namr.com/?option=filter&option2=&option3= http://www.domain-namr.com/?option=filter&option2=&option3=
I am trying to redirect all of these to a new URL in HTACCESS with this code - 我正在尝试使用此代码将所有这些重定向到HTACCESS中的新URL-
RewriteCond %{REQUEST_URI} ^/$
RewriteCond %{QUERY_STRING} ^option=filter$
RewriteRule ^(.*)$ /new-url.html [R=301,L]
Of course it is not working. 当然不行了。 On all of the pages that have a filename I can use in the request uri condition, the redirects work.
在可以在请求uri条件中使用的文件名的所有页面上,重定向均有效。 What am I missing?
我想念什么?
It is not working due to the wrong regex pattern in your rule. 由于规则中的正则表达式模式错误,因此无法正常工作。
Try this rule as your very first rule in root .htaccess: 尝试将此规则作为根.htaccess中的第一个规则 :
RewriteCond %{QUERY_STRING} ^option=filter(&|$) [NC]
RewriteRule ^$ /new-url.html? [R=301,L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.