Nginx服务器默认不支持pathinfo, 在需要pathinfo支持的程序中(如thinkphp),则无法支持”/index.php/Home/Index/index”这种网址.
网上流传的解决办法很多,这里提供一种比较简洁的写法(只需要改动2行代码)
<code><span># 典型配置</span><span>location</span><span>~ \.php$</span> { <span>root</span> html; <span>fastcgi_pass</span><span>127.0.0.1:9000</span>; <span>fastcgi_index</span> index.php; <span>fastcgi_param</span> SCRIPT_FILENAME <span>$DOCUMENT_ROOT</span><span>$fastcgi_script_name</span>; <span>include</span> fastcgi_params; } <span># 修改第1,6行,支持pathinfo</span><span>location</span><span>~ \.php(.*)$</span> { <span># 正则匹配.php后的pathinfo部分</span><span>root</span> html; <span>fastcgi_pass</span><span>127.0.0.1:9000</span>; <span>fastcgi_index</span> index.php; <span>fastcgi_param</span> SCRIPT_FILENAME <span>$DOCUMENT_ROOT</span><span>$fastcgi_script_name</span>; <span>fastcgi_param</span> PATH_INFO <span>$1</span>; <span># 把pathinfo部分赋给PATH_INFO变量</span><span>include</span> fastcgi_params; }</code>
以上就介绍了 nginx支持pathinfo模式,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。