Hello,
recently I migrate one of domains, I manage, to use try_files directive instead of several "if" blocks and rewrites. New server description is like this:
server {
listen X.X.X.X;
server_name example.com *.example.com;
index index.php;
root /www/example.com/www/root;
try_files $uri $uri/ /index.php$is_args$args;
location ~* \.(jpg|jpeg|gif|png|ico|swf)$ {
gzip off;
expires 7d;
}
location ~* \.(js|css)$ {
expires 7d;
}
location ~ \.php$ {
fastcgi_pass upstreanphp;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors on;
fastcgi_read_timeout 120;
fastcgi_next_upstream error timeout invalid_header;
include fastcgi_params;
}
}
Strange thing (for me) is if I try some URL like http://example.com/path/to/non/existing/file.jpg (or any other extension from location checks) I receive error 404. Is this normal behavior ? I expect index.php to be open. I've tried to put try_files in location / { } , but effect is the same ? Do I have to put try_files in every location block ? Or this is some kind of bug ?
I use nginx 0.8.54 on linux x86_64
Greetings,
Hristo