Go to content Go to menu

? is a reserved character in the HTTP protocol. Any half-baked web developer can tell you that servers are supposed to treat everything after it with special regard, sucking them in to the flow of the request as variables.

Let’s keep it brief. Here’s the hack. You probably tried:

RewriteCond %{THE_REQUEST} [\?]+
RewriteRule ^/(.*) /$1\%3F%{QUERY_STRING} [NE]

but that’s insufficient, you get an error log entry as by this point, showing that apache is looking on the filesystem for a file containing a urlencoded “?”, i.e. “blabla%3Fsomecrud”.

So here’s what actually works:

RewriteCond %{THE_REQUEST} [\?]+
RewriteCond %{THE_REQUEST} !%3F.*?\?
RewriteRule ^/(.*) /$1\%3F%{QUERY_STRING} [NE,R]

The redirect is necessary to fire off another request to apache containing the %3F so that it can be correctly parsed back into a ?

The problem is that your request goes through Apache’s modules in a serial fashion, and there’s a module toward the front of this processing queue that decides what part of your request needs to be decoded before mapping it to a named entity on the filesystem. This isn’t a bug in apache, it’s the natural order of things – rules are there to be broken after all.