0

I am using nginx 1.8 and knowing about the alias/try_files bug i wrote the following nginx conf:

root /var/www/
location  /foo/ {
   root /var/www/projects/bar/public/;
    try_files $uri $uri/ index.php;

}

in which i get a 404, but if i write the following way (which should point to the same location)

  root /var/www/
  location   ~ ^/foo/(.*)$  {
    try_files /projects/bar/public/$uri /projects/bar/public/$uri/ /projects/bar/public/index.php;

 }

i get the contents. Why the other root seems not to be applyied?

Community
  • 1
  • 1
FabioCosta
  • 3,069
  • 6
  • 28
  • 50
  • 1
    Have a look at the nginx error log, it'll show you the final path it's trying to use. I think it may be trying /var/www/projects/bar/public/foo/ – bnx May 08 '15 at 12:00
  • Yes that would be true for $uri and $uri/ but not for index.php (that was the final destination). No noticeable error on error.log, funy thing though i created a new virtual server with the same root and all work as intended. I just wanted to know why 1 is wrong in what concerns the index.php – FabioCosta May 08 '15 at 15:09

0 Answers0