Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

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.

share|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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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