Yaf 框架需要 Nginx 开启 Pathinfo 并且正确配置 否则会出现各种404 500 跳转首页等 折腾了好久 下面是在 Nginx 1.15.7 下的正确配置

server {
    listen       80;
    server_name  api.io;
    root   /www/api.io;
    index  index.php index.html index.htm;

    if (!-e $request_filename) {
        rewrite ^/(.*)  /index.php/$1 last;
    }


access_log  /var/log/nginx/nginx.api.io.access.log;
error_log  /var/log/nginx/nginx.api.io.error.log;

#error_page  404              /404.html;

# redirect server error pages to the static page /50x.html
#
error_page   500 502 503 504  /50x.html;
location = /50x.html {
    root   /usr/share/nginx/html;
}


# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
# location ~ \.php$ {
#     fastcgi_pass   php70:9000;
#     fastcgi_index  index.php;
#     include        fastcgi_params;
#     fastcgi_param  PATH_INFO $fastcgi_path_info;
#     fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
#     fastcgi_split_path_info  ^(.+\.php)(/.+)$;
# }

location ~ [^/]\.php(/|$){
    fastcgi_pass   php70:9000;
    fastcgi_index  index.php;

    include        fastcgi_params;      
        
    set $path_info "";
    set $real_script_name $fastcgi_script_name;
    if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
        set $real_script_name $1;
        set $path_info $2;
    }
    fastcgi_param PATH_INFO       $path_info;
    fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
    fastcgi_param SCRIPT_NAME     $real_script_name;
}

参考资料

https://nginxconfig.io/