2.使用nginx正则解析,手动用if命令将访问路径解析,然后作为PATH_INFO传递给php页面。
Nginx默认获取不到PATH_INFO的值,得通过fastcgi_split_path_info指定定义的正则表达式来给$fastcgi_path_info赋值。
#配置方案 使用nginx模块fastcgi_split_path_info(nginx版本>0.7.31)
location ~ .php {
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
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;
-
}