Nginx Rewrite rule to replace '?' with %3f Nginx Rewrite rule to replace '?' with %3f nginx nginx

Nginx Rewrite rule to replace '?' with %3f


You should url-encode your query string to escape special characters such as ? and =

Specifically, the name of your file you have to request for, once encoded, is this:

foo%3Flang%3Dar.html 

In Javascript you can url-encode the filename with encodeURIComponent() function, in PHP you have urlencode().


You MUST encode the ? as %3F before the http call to nginx.

The reason is that the url rfc reserves the ? character as a special character (specifcally see section 3.3). Consequently nginx will, correctly, interpret an unescaped ? character as the end of the path part of the url