每当我在 url nginx return 中放置一个已知的文件扩展名时404 Not Found
。
domain.com/myroute.foo
anddomain.com/foo/myroute.foo
很好,但是domain.com/myroute.php
and domain.com/foo/myroute.php
(或例如 .css、.js)返回404 Not Found
.
我的 nginx 服务器配置:
server {
listen 80;
server_name domain.com;
root /var/www/path/public;
charset utf-8;
gzip on;
#access_log logs/host.access.log main;
location / {
index index.html index.php index.htm;
try_files $uri $uri/ /index.php?q=$uri&$args;
}
location ~ \.php$ {
try_files $uri = 404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
include fastcgi_params;
}
location ~* \.(jpg|jpeg|gif|png|bmp|ico|pdf|flv|swf|exe|html|htm|txt|css|js) {
add_header Cache-Control public;
add_header Cache-Control must-revalidate;
expires 7d;
access_log off;
}
}
为什么具有已知文件扩展名 ( ) 的 url 不能像任何其他 url 一样/myroute.php
访问我的文件?index.php