try_files internal redirect stripping QUERY_STRING?

Jeff Waugh jdub at bethesignal.org
Fri Nov 13 06:28:48 MSK 2009


Hi all,

Using a fairly bog-standard try_files -> php/fastcgi config here with nginx
0.8.22. Looks very much like this:

  index  index.php;

  location / {
    try_files  $uri $uri/  /index.php;
  }

  location ~ \.php$ {
    include  fastcgi_params;
    fastcgi_pass  fcgi_php; # defined in an upstream
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
  }

With http://example.com/?test=test the QUERY_STRING = 'test=test'.

With http://example.com/path/?test=test the QUERY_STRING = '', while the
REQUEST_URI is correct (ie. also contains the query string).

Looking at the debug log, I noticed that at one point, nginx seems to be
doing an internal redirect to "/index.php?" -> if that question mark means
the same thing as it does in a configured rewrite, try_files is stripping
the query string!

I suspect that /?test=test is working because $uri/ is tested with the
index, thus becoming /index.php?test=test.

Thoughts?

- Jeff

-- 
linux.conf.au 2010: Wellington, NZ                http://www.lca2010.org.nz/
 
   "Do you know what [television news ownership] means to me? It gives me
                the political muscle I need." - Kerry Packer





More information about the nginx mailing list