I have the following .htaccess file:
RewriteEngine On
# Rewrite www.
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Suppose my domain is foo.com. If I open http://foo.com/something, it will be redirected to http://www.foo.com/something. This works nicely, except when something contains any url encoded characters.
If I open http://www.foo.com/bar/file-with-%3F-in-name, the REQUEST_URI is /bar/file-with-%3F-in-name.
If I open http://foo.com/bar/file-with-%3F-in-name, however, the url encoded %3F is decoded to ? during rewrite, and the REQUEST_URI becomes /bar/file-with- with the QUERY_STRING -in-name.
How can I keep the url encoded characters from being decoded during rewrite?