Reputation: 4111
I need to 301 redirect an old url that contained a get parameter in the url.
I need to 301 the URL:
http://www.website.com/choose?cat=womens
to this URL:
http://www.website.com/womens
I have searched and tried without it working:
RewriteCond %{QUERY_STRING} cat=womens
RewriteRule ^choose\.php$ /womens [L,R=301]
Where am I going wrong?
Upvotes: 1
Views: 999
Reputation: 1
Try these:
RewriteCond %{QUERY_STRING} ^cat=womens$
RewriteRule ^choose$ http://www.website.com/womens? [R=301,L]
Upvotes: -1
Reputation: 786349
You're almost correct, just 2 issues:
.php
wasn't there in your original URI after choose
as per the question?
in target to strip original query stringYou can use:
RewriteCond %{QUERY_STRING} (?:^|&)cat=([^&]+) [NC]
RewriteRule ^choose(?:\.php)?$ /%1? [L,R=301,NC]
Upvotes: 2