I'm running into bad URLs that contain an escaped line-feed in the following format:
http://domain.com/%0Apath/to/file.txt
However, even if I try the most global rewrite possible...
RewriteRule ^.*$ /path/to/file.txt [R=301,L]
...Apache still throws a 404:
The requested URL / path/to/file.txt was not found on this server.
(Note the space.)
How can I gracefully intercept these bad URLs and route them to the right destination?
This is very old question but I think none of the answer are right so posting an answer:
Replace your rule with this:
^.*$
won't span the linefeed. Try a plain.*
. Alternatively, try matching on the newline characters:[\r\n]
.I had the same Problem. I fixed it with the help of sarumont's answer.
Example URL, found in Webmaster Tools:
Rewrite Rule that I added in Apache config:
Adding
\s
to the RewriteRule should fix it.More specifically as a catch-all