默認情況下,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。