Directory fallback

merlin corey merlincorey at dc949.org
Thu Jan 7 21:30:54 MSK 2010


On Wed, Dec 30, 2009 at 3:39 AM, Tobia Conforto
<tobia.conforto at gmail.com> wrote:
> Eureka!
>
> Final version, accomplishing all my objectives:
>  - site dir, with fallback to base dir;
>  - static files directly, php files through fastcgi;
>  - not calling fastcgi on nonexistent files;
>  - not using "if" (somebody mentioned performance problems?)
>
> location / {
>  root /var/www/site1;
>  try_files $uri @base;
> }
> location @base {
>  root /var/www/base;
> }
> location ~ \.php$ {
>  root /var/www/site1;
>  try_files $uri @basephp;
>  fastcgi_pass 127.0.0.1:9000;
> }
> location @basephp {
>  root /var/www/base;
>  try_files $uri ERROR;
>  fastcgi_pass 127.0.0.1:9000;
> }
>
> Is there anything nicer I can put in the last try_files, instead of the nonexistent file "ERROR"?
>
> Tobia
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://nginx.org/mailman/listinfo/nginx
>

The final parameter for try_files SHOULD be a guaranteed to exist
location (such as your static 404 page).

if does indeed add a bit of overhead into things but there's no real
numbers to suggest how much -- for most purposes it's obviously not
TOO much, but there's no point in wasting resources just to waste
them, either.

-- Merlin

`



More information about the nginx mailing list