another rewrite/try files issue

Stelianos G. Sfakianakis sgsfak at gmail.com
Mon May 23 23:31:31 MSD 2011


2011/5/23 brianmercer <nginx-forum at nginx.us>:
> Oh, I see.  Maybe this:
>
> location ~ /myapp/(?<myquery>.*) {
> root /home/stelios;
> try_files $uri /myapp/index.php?u=/$myquery;
> }
>
> location = /myapp/index.php {
> fastcgi_pass 127.0.0.1:9000;
> fastcgi_param SCRIPT_FILENAME /home/stelios/myapp/index.php;
> include fastcgi_params;
> }

Thanks again!

I finally did the following which seems to work just fine:

location ~ /myapp/(.*) {
     root /home/stelios/myapp;
     set $args u=/$1&$args;
     try_files /$1 @fallback;
}
location @fallback {
     root /home/stelios/myapp;
    fastcgi_pass 127.0.0.1:9000;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root/index.php;
}

The "set $args ..." directive augments the QUERY_STRING with the
original uri that is kept to the subsequent fastcgi call.

Best regards
Stelios



More information about the nginx mailing list