在Nginx服务器pathinfo配置说明

时间:2023年05月04日

/

来源:网络

/

编辑:佚名

EaglePHP 框架默认采用 pathinfo 做资源定位,所以要求 $_SERVER 环境变量中必须要有 PATHINFO。
一般在 apache 或者 iis 下都没有什么问题,但是在 nginx 下需要对配置文件做一些设置才可以。
把下面的代码保存为 pathinfo.conf 文件,存放在 nginx 的 conf 目录下
set $real_script_name $fastcgi_script_name; 
if ($fastcgi_script_name ~ "(.+?\.php)(/.+)") { 
    set $real_script_name $1; 
    set $path_info $2; 

fastcgi_param SCRIPT_FILENAME $document_root$real_script_name; 
fastcgi_param SCRIPT_NAME $real_script_name; 
fastcgi_param PATH_INFO $path_info;
修改 nginx.conf 里的
location ~ \.php${} 这几行部分为
location ~ .*\.php { #去掉 $ ,以便能匹配所有 *.php/* 形式的 url
root /wnmp/www;
fastcgi_pass 127.0.0.1:9000;
#fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
include pathinfo.conf;
}
注意红色部分。
猜你需要

豫ICP备2021026617号-1  豫公网安备:41172602000185   Copyright © 2021-2028 www.78moban.com/ All Rights Reserved

本站作品均来自互联网,转载目的在于传递更多信息,并不代表本站赞同其观点和对其真实性负责。如有侵犯您的版权,请联系 1565229909#qq.com(把#改成@),我们将立即处理。