#例访问路径 http://127.0.0.1/mall/a.php
location /mall/ {
alias D:/web/mall/public/;
location ~ \.php$ {
# 此时
# $document_root 为 D:/web/mall/public/
# $fastcgi_script_name 为 /mall/a.php
# 如果SCRIPT_FILENAME直接用$fastcgi_script_name,实际寻找路径会成为D:/web/mall/public/mall/a.php
set $real_script_name $fastcgi_script_name;
if ($fastcgi_script_name ~* "/mall/(.+\.php)$") {
set $real_script_name $1;
}
fastcgi_pass 127.0.0.1:20074; #此处根据自己实际配置,我的是宝塔环境php7.4
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
include fastcgi_params;
}
}