[英]Nginx returns a 404 for URLs like index.php/some/path
當我查詢在腳本名稱后附加“路徑信息”的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 {
fastcgi_split_path_info ^(。+ ?. php)(/.*)$;
匹配uri中的.php拆分參數
這對我有用:
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;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.