当我查询在脚本名称后面附加了"path info“的网址时,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$与这个网址不匹配,我也尝试过搜索类似的问题,但没有找到任何有用的东西。
发布于 2014-10-15 14:31:55
使用
位置~ ^.+.php {
fastcgi_split_path_info ^(.+?.php)(/.*)$;
若要匹配uri中的.php,请拆分参数。
发布于 2016-03-20 05:25:37
这对我来说很有效:
location ~ \.php {
# Split the path appropriately
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
# Work around annoying nginx "feature" (https://trac.nginx.org/nginx/ticket/321)
set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;
# Make sure the script exists.
try_files $fastcgi_script_name =404;
# Configure everything else. This part may be different for you.
fastcgi_pass localhost:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}https://stackoverflow.com/questions/26374986
复制相似问题