Redirect not working


I have the following rewrite, but it doesn’t seem be happening.

Any ideas why its not working?

RewriteCond %{QUERY_STRING} ^ref=ref1$
RewriteRule ^$ [R=301,L]


You can’t put the schema, domain and query string in the RewriteRule, plus . should be escaped as \. because dots have a special meaning in regular expressions. It should be

RewriteCond %{QUERY_STRING} ^ref=ref1$ 
RewriteRule ^subfolder/page1\\.shtml$ /subfolder/page2.shtml?ref=ref2 [R=301,L]

(you could leave the [noparse][/noparse] in the RewriteRule for the destination, but if the domain doesn’t change I’d recommend against this. It’s not needed and easier to change domain names later if you ever need to).