Try_files internal redirect stripping QUERY_STRING?

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 Example Domain 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

On Fri, Nov 13, 2009 at 10:28 AM, Jeff W. [email protected]
wrote:

  • 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

I believe you can still get it with $_GET[‘var’] variable

I believe you can still get it with $_GET[‘var’] variable

If it’s not in QUERY_STRING, it won’t make it into PHP’s $_GET.

  • Jeff

On Fri, Nov 13, 2009 at 11:32 AM, Jeff W. [email protected]
wrote:

I believe you can still get it with $_GET[‘var’] variable

If it’s not in QUERY_STRING, it won’t make it into PHP’s $_GET.

  • Jeff

oh right it isn’t.

make it

try_files $uri $uri/ /index.php?$args;

On Fri, Nov 13, 2009 at 1:28 PM, Jeff W. [email protected]
wrote:

I believe since it’s usually used for parsing REQUEST_URI (clean urls,
etc), I don’t think it’s intended to pass QUERY_STRING at all.

On Fri, Nov 13, 2009 at 11:32 AM, Jeff W. [email protected] wrote:

If it’s not in QUERY_STRING, it won’t make it into PHP’s $_GET.

oh right it isn’t.

make it

try_files $uri $uri/ /index.php?$args;

Right… thanks, that works, but it feels unbelievably dirty. :slight_smile:
Wondering
if Igor regards this as intentional behaviour or not…

  • Jeff