The problem I’m having is querystrings persisting through a redirect. I.e., whenever I try and redirect a URL of type
RewriteRule ^oldsite/product/productname.aspx http://subdomain.newsite.com/product [L,R=301]
this works perfectly – no issues.
However, when I try this with anything with a querystring, such as:
RewriteRule ^oldsite/product/productname.aspx?=QUERYSTRING http://subdomain.newsite.com/product [L,R=301]
the redirect works, but I end up with the following result when I check it with a header checker:
http://subdomain.newsite.com/product?=QUERYSTRING
i.e. – it passes the querystring from the old URL, and I do not want it to.
I checked a bunch of resources but can’t seem to find a simple solution to this. Is there a flag I am missing within the square parameters brackets? (Sorry if I’m using the wrong terminology, new to mod_rewrite.)
If you append a ? to your target URL, the query string will be removed from the redirection: