Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Nginx is serving only static files, yet, some of file names contains '?'. Yes, the question mark.

All URLs that contains '?' yield 404 even though file actually exists. e.g.

> GET /foo?lang=ar.html HTTP/1.1
< HTTP/1.1 404 Not Found

While a file named foo?lang=ar.html does exists in the expected location.

I wonder if there is a way to tell Nginx to treat the entire request as URL including what is currently translated as query string.

The only solution I have in mind is to write a small web server that does this and have nginx reverse proxy that web server, but I prefer get it done with nginx alone.

share|improve this question
Well, a question mark is a special character that denotes the start of the query string, so it can never be part of the file name.. I can't test right now but maybe try replacing it in the URL with the escaped version, %3f. – Shane Madden Oct 5 '12 at 16:40
@ShaneMadden That will work, but how would you be able to differentiate between a filename and just an URI pointing to a CGI accepting parameters? Looks like this is going to be an administrative nightmare. :) Edit: It will definetly work. Just tried it on my webserver and I got an GET /header.php%3fbla HTTP/1.1" 404. – Alexander Janssen Oct 5 '12 at 17:24
up vote 6 down vote accepted

You can use try_files with either $request_uri or $uri$is_args$args depending on whether you want to have the urlencoded bits decoded or not when looking for the filename.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.