another rewrite/try files issue

Stelios Sfakianakis sgsfak at
Mon May 23 10:53:08 MSD 2011

On 23/5/2011 1:06 πμ, brianmercer wrote:
> Possibly this:
> location /myapp/ {
>    root /home/stelios;
>    try_files $uri @fallback;
> }
> # and the "default" PHP/FastCGI
> location @fallback {
>    fastcgi_pass;
>    fastcgi_param SCRIPT_FILENAME /home/stelios/myapp/index.php;
>    include fastcgi_params;
> }

Thanks Brian, that *almost* works (although I don't like repeating [most 
of] the fastcgi config..)

But I also need to pass *part* of the original path as a query string. I 
tried to following :

location @fallback {
       include fastcgi_params;
       fastcgi_param SCRIPT_FILENAME /home/stelios/myapp/index.php;
       fastcgi_param  QUERY_STRING  u=$uri&$args;

which works but now for the url ".../myapp/users" the script gets a 
query string like this: "u=/myapp/users" whereas I want it to be 
"u=/users" (i.e. remove the "base" path). Is there any simple solution 
to that? (e.g. can we pass parameters to a named location?)


More information about the nginx mailing list