try_files and GET variables

Igor Sysoev is at rambler-co.ru
Mon Mar 30 19:48:05 MSD 2009


On Mon, Mar 30, 2009 at 06:14:25PM +0300, Reinis Rozitis wrote:

> >The attached patch fixes the bug.
> 
> It fixed the garbage part then again QUERY_STRING is now empty at all.. Or 
> is this expected?
> 
> 
> In short what I try to archieve is this - if you have:
> 
> location /tmp {
>    try_files $uri /index.php;
> }
> 
> And open something like http://myserver/tmp/somecategory/another/?id=234 
> php still gets 'id' as normal GET variable..

If you want to preserve query_string, then you should use

    try_files $uri /index.php?$args;

> The rewrite or error_page alternative would be:
> 
> rewrite  ^/tmp/(.*)$ / last;
> 
> location /tmp/ {
>        error_page   404 =         /index.php;
> }
> 
> 
> 
> 
> I somehow see this conflicting if you specify something like this in the 
> config
> 
> location /tmp {
>    try_files $uri /index.php?q=$request_uri;
> }
> 
> Then again it gets messy if you want to split the query_string on php side 
> and assign all the variables.. Besides try_files looks way more superior 
> than both previous approaches..


-- 
Igor Sysoev
http://sysoev.ru/en/





More information about the nginx mailing list