繁体   English   中英

Nginx对于诸如index.php / some / path之类的URL返回404

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM