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