Reputation: 3
We have a bunch of URLs that were indexed by Google with special apostrophes (url encoded as '%E2%80%99'). We corrected the urls on the server, but Google is still pointing there and we didn't want to interrupt any SEO mojo here. Any thoughts why this won't work?
Current rewrite rule in .htaccess file:
# remove apostrophes from a string
RewriteRule ^(.*)’(.*)$ /$1$2 [L,R=301]
RewriteRule ^(.*)%E2%80%99(.*)$ /$1$2 [L,R=301]
Example replace this URL:
http://example.com/santa%E2%80%99s-comin-to-town/
with this URL:
http://example.com/santas-comin-to-town/
Upvotes: 0
Views: 498
Reputation: 774
Try using this:
RewriteRule ^(.*)’(.*)$ /$1$2 [B,L,R=301]
RewriteRule ^(.*)([^\w].+\d)(.*)$ /$1$3 [B,L,R=301]
using the %
character can have adverse effects on rewrite rules:
(%..%..%..) or (\%..\%..\%..)
should also work, although make sure you provide the [B]
flag on the end of the rule.
Upvotes: 1
Reputation: 786289
Use this rule for using hex code in rewrite rules:
RewriteRule ^(.*)\xE2\x80\x99(.*)$ /$1$2 [L,R=301]
Upvotes: 0