Redirect not working

Hi,

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

Any ideas why its not working?


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

Thanks

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]http://www.domain.com[/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).

:slight_smile: