I’m trying to do some relatively simple .htaccess rules to 301 redirect some URLs. The rules are not matching. Here is what I have:
RewriteEngine On
RewriteBase /
# This works fine
RewriteCond %{QUERY_STRING} ^id=2$ [NC]
RewriteRule ^products\.php$ /? [R=301,NE,NC,L]
# This doesn't match at all
RewriteRule ^products/-Smart-Smoker-\'Storm\'-White-Manual-Electronic-Cigarette-\(510\)\.html http://www.smartsmoker.co.uk/products/-Smart-Smoker-Storm-White-Manual-Electronic-Cigarette-%28510%29.html [NC,R=301]
# Neither does this
RewriteRule ^products/Christmas-Cracker-%252d-FREE-Shipping\.html$ http://www.smartsmoker.co.uk/categories/Electronic-Cigarette-Kits/Breeze-Mini-Electronic-Cigarette/ [L,R=301]
Best bet when having rewrite drama is to break it down into the shortest functioning match then expand on it noting that conditions above might be affecting what you want to actually test. Having said that, I can’t see any problems myself using the minimal example below:
Also the URLs you redirect to don’t have to be URL encoded.