another rewrite/try files issue

António P. P. Almeida appa at perusio.net
Tue May 24 00:25:11 MSD 2011


On 23 Mai 2011 20h31 WEST, sgsfak at gmail.com wrote:

> 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;
> }

You can do it without any set directive. Try this.

location ~ /myapp/(?<myquery>.*)$ {
  root /home/stelios/myapp;
  try_files /$myquery /index.php?u=/$myquery&$args;
}

location = /index.php {
   root /home/stelios/myapp;     
   fastcgi_pass 127.0.0.1:9000;
   include fastcgi_params;
   ## Remove the line below if already defined in fastcgi_params.
   fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
}

--- appa



More information about the nginx mailing list