Configure Nginx to support pathinfo mode nginx pathinfo support nginx rewrite pathinfo nginx pathinfo support

WBOY
Release: 2016-07-29 08:49:02
Original
1073 people have browsed it

让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>
Copy after login

修改第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>
Copy after login
').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教程有兴趣的朋友有所帮助。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!