【发布时间】:2014-10-15 05:18:26
【问题描述】:
当我查询一个在脚本名称后附加“路径信息”的 URL 时,Nginx 返回 404,例如http://example.com/index.php/hello.
这是我的配置:
server {
listen 80;
root @PROJECT_ROOT@/;
index index.php index.html;
location ~ \.php$ {
fastcgi_pass unix:@PHP_FPM_SOCK@;
include fastcgi_params;
fastcgi_read_timeout 300s;
}
}
我不明白为什么\.php$ 与那个 URL 不匹配,我尝试搜索类似的问题但找不到任何有用的东西。
【问题讨论】:
-
\.php$模式强制 nginx 只匹配以.php结尾的 URL。你为什么不看看流行的框架是如何安排这个设置的,比如 Symfony2? symfony.com/doc/current/cookbook/configuration/… -
@softius 好点!谢谢