We're trying to clean up some 404's on our site and some website is linking to /page.html%C2%A0. I'm trying to match the url with mod rewrite and redirect it to /page.html

RewriteRule ^page.html%C2%A0 /page.html [R=301,L]

This doesn't seem to match the url, I've also tried escaping the percent signs to \%, but that doesn't match either.

Anyone know how to get it working?

link|improve this question

67% accept rate
feedback

1 Answer

up vote 0 down vote accepted

From looking at your example, I think the problem is likely that you didn't include the leading / that's part of the request. The apache mod_rewrite docs do say that a \ should work. Try:

RewriteRule ^/page.html%C2%A0 /page.html [R=301,L]

Or:

RewriteRule ^/page.html\%C2\%A0 /page.html [R=301,L]

If none of those work for some reason, you could always try hitting it with a bigger hammer (a more inclusive ruleset that avoids using the special characters explicitely):

RewriteRule ^/?page.html.+ /page.html [R=301,L]

That will redirect page.html (with or without a leading /) followed by one or more of any character to just straight /page.html.

link|improve this answer
I ended up hitting it with the biggest hammer to get it working and use the ^page.html.+ regex. Thanks. – Noodles Nov 15 '10 at 2:24
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.