Reputation: 10609
I have a site that has a bunch of URLs indexed in Google that look like this -
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 -
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. What am I missing?
Upvotes: 1
Views: 926
Reputation: 784958
It is not working due to the wrong regex pattern in your rule.
Try this rule as your very first rule in root .htaccess:
RewriteCond %{QUERY_STRING} ^option=filter(&|$) [NC]
RewriteRule ^$ /new-url.html? [R=301,L]
Upvotes: 1