try_files does not have any effect on existing files

weheartwebsites nginx-forum at forum.nginx.org
Sun Feb 19 17:42:11 UTC 2017


usually you would have something like this in your config:

location / {
  try_files $uri $uri/ /index.php
}

which works pretty good (1.11.10) - however it seems, that if you are
requesting a physical file it will work anyway und the try_files gets
ignored - so the following will work just as well:

location / {
  try_files /foobar /index.php
}

This means, I can not for example overwrite an existing physical file
location with a config like this:

location / {
  try_files /$host$uri /index.php
}

Since if $uri exists under the root/alias it will be served directly without
triggering that try_files directive.

Am I doing something wrong - or is this expected behaviour?

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,272503,272503#msg-272503



More information about the nginx mailing list