Directory fallback

Tobia Conforto tobia.conforto at gmail.com
Wed Dec 30 14:39:34 MSK 2009


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


More information about the nginx mailing list