Nginx 虚拟主机下支持Pathinfo并隐藏入口文件的完整配置

时间:2022-01-29 17:47:22
server {
listen 80;
server_name zuqiu.com;  # 设置你的域名
index index.html index.htm index.php;
root D:/wnmp/www/dev/zuqiu;    # 设置你的程序路径 location ~ \.php {
root D:/wnmp/www/dev/zuqiu;  # 设置你的程序路径
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params; # 对PATHINFO的支持
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_param PATH_INFO $fastcgi_path_info; } # 隐藏入口文件
location / {
if (!-e $request_filename){
rewrite ^/(.*)$ /index.php/$1 last;
break;
}
}
}