默认情况下,nginx是不支持path_info的,我们需要做些配置让它支持。
location ~ .php(.*)$ { root /var/www/nginx/html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_split_path_info ^(.+.php)(.*)$; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; include fastcgi_params; }
备注:
1. ~ .php改为~ .php(.*),因为要接收.php后面的参数,不能让它被当做目录处理。
2. 添加fastcgi_split_path_info,该参数后面需指定正则表达式,而且必须要有两个捕获,第一个捕获将会重新赋值给$fastcgi_script_name,第二个捕获将会重新赋值给$fastcgi_path_info。
3. 添加fastcgi_param PATH_INFO,值为$fastcgi_path_info。