nginx 子目录执行php

location ^~ /sub/ {
set $subroot /home/www/sv8/wwwroot/;
root $subroot;
index index.php index.html;

location ~ .php {
fastcgi_pass php5:9000;
set $scriptname '';
set $pathinfo '';

if ( $uri ~ ^/sub/(.+.php)($|/.+) ) {
set $scriptname $1;
set $pathinfo $2;
}

fastcgi_param SCRIPT_FILENAME /home/www/sv8/wwwroot/$scriptname;
fastcgi_index index.php?IF_REWRITE=1;
fastcgi_param PATH_INFO $pathinfo;
include fastcgi_params;
}
}

原文地址:https://www.cnblogs.com/linuxOS/p/15422356.html