Forum Moderators: phranque

Message Too Old, No Replies

Query String help

         

Lidders

11:07 am on Jul 28, 2011 (gmt 0)

10+ Year Member



Hi All.

New here. Been searching threads for several days and hoped to get some help from someone please.

I have a lot of URLs that are duplicated in the SERPs because of a query string. These URLs are now no longer needed (the option on the site that generated them has been removed) so I want to get rid of them. The query string is ?currency=EUR

URL structures are as follows:

www.example.com/product-name-product-number.html?currency=EUR

www.example.com/category-name-category-number.html?currency=EUR

Basically I just need to get rid of the query string and keep the rest of the url the same so:

www.example.com/product-name-product-number.html?currency=EUR would redirect to
www.example.com/product-name-product-number.html

and

www.example.com/category-name-category-number.html?currency=EUR would redirect to
www.example.com/category-name-category-number.html

etc

Would the following do the trick?

RewriteCond %{QUERY_STRING} ^currency=EUR$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1? [R=301,L]


There is already a working rewrite rule in htaccess directing non-www to www. Would the query string rule need to go before or after that, or does it not matter?

I suspect that is probably too simplistic but I'm still getting my head round this so any help would be greatly appreciated.

Many thanks

lucy24

9:08 pm on Jul 28, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If "currency=EUR" is always the only thing in the query, then your version will work. The question mark followed by nothing is exactly what you want. If there is a possibility of longer queries including both "currency=EUR" and other things that you need to keep, it gets a little more complicated.

Put the redirect involving "www" last of all, to pick up anything that hasn't already been rewritten for other reasons.