I had been utilizing a .htaccess redirect 301 to redirect a URL which in turn appended all of the query string elements towards the finish, departing me with a few Web addresses indexed in the search engines as /store/product/?d=department&s=section&p=product.

I've fixed the redirect using a RewriteRule rather which does not append the query strings, however I am stuck attempting to rewrite that old rerouted Web addresses using the query strings to the initial Web addresses (because these are searching like two different Web addresses to Google now).

I've handled to obtain a RewriteRule to kind of work, for the reason that /store/product/xxxxx redirects to /store/product/ because it should, it simply does not appear to utilize the entire query string of.

What I've been using is:

RewriteRule ^store/product/([a-zA-Z0-9\-_\?=&]+)$ http://www.example.com/store/product/ [NC,R=301,L]


RewriteRule ^store/product/\?d=department&s=section&p=product$ http://www.example.com/store/product/ [NC,R=301,L]

Hope that is sensible!

Thank you

RewriteCond %{QUERY_STRING} !^$
RewriteRule ^store/product/.*$ http://www.example.com/store/product/? [NC,R=301,L]

You have to specify a clear query inside your substitution to do not have the original one instantly appended towards the new URL:

RewriteRule ^store/product/[a-zA-Z0-9\-_=&]+$ http://www.example.com/store/product/? [NC,R=301,L]

Note the ? in the finish from the substitution URL.