nginx支持pathinfo模式

来源:互联网 发布:mac压感 编辑:程序博客网 时间:2024/04/28 06:07

Nginx服务器默认不支持pathinfo, 在需要pathinfo支持的程序中(如thinkphp),则无法支持”/index.php/Home/Index/index”这种网址.

网上流传的解决办法很多,这里提供一种比较简洁的写法(只需要改动2行代码)

# 典型配置location ~ \.php$ {    root           html;    fastcgi_pass   127.0.0.1:9000;    fastcgi_index  index.php;    fastcgi_param  SCRIPT_FILENAME  $DOCUMENT_ROOT$fastcgi_script_name;    include        fastcgi_params;}# 修改第1,6行,支持pathinfolocation ~ \.php(.*)$ { # 正则匹配.php后的pathinfo部分    root html;    fastcgi_pass   127.0.0.1:9000;    fastcgi_index  index.php;    fastcgi_param  SCRIPT_FILENAME  $DOCUMENT_ROOT$fastcgi_script_name;    fastcgi_param PATH_INFO $1; # 把pathinfo部分赋给PATH_INFO变量    include        fastcgi_params;}
0 0
原创粉丝点击