I have a problem that a marketing e-mail was sent out to clients with a link to our website, but it ended in a space. In other words, it goes to something like http://www.example.com/somepage/%20
. Sending another e-mail with a correct link would probably be seen by the clients as spam, so we're trying to fix it on our end.
I tried adding a redirect rule to .htaccess
, but it is failing before it gets to that point.
The Apache error log shows the following error:
(20024)The given path is misformatted or contained invalid characters: Cannot map GET /cost-per-invoice-calculator/%20 HTTP/1.1 to file
Any suggestions? This is Apache on a Windows server, if that is relevant...
It looks like this is something that has been given status WONTFIX by the Apache team: https://issues.apache.org/bugzilla/show_bug.cgi?id=41441
OK, this is on a Linux server, but I don't appear to have a problem redirecting a URL that contains a space:
This performs the following redirection:
EDIT: Yes, as per Ernest Mueller's comment, this is in the server config, not in .htaccess
.htaccess is parsed pretty late in the game, I bet Cez was doing it in his httpd.conf, allowing it to proc before the bad character check that triggers on the space.
Also, if your Apache is fronted by some kind of load balancer or proxy or whatnot, doing the rewrite there would definitely work.