简单配置nginx使之支持pathinfo

 在nginx下搭建thinkphp网站之后访问报错404,那是因为pathinfo支持不好,需要配置下nginx的配置文件使他兼容,配置如下。

location ~ \.php(/|$) {
     root          H:/PHPServer/WWW;
     fastcgi_pass   127.0.0.1:9000;
     fastcgi_index  index.php;
     fastcgi_split_path_info ^(.+\.php)(.*)$;     #增加这一句
     fastcgi_param PATH_INFO $fastcgi_path_info;    #增加这一句
     fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
     include        fastcgi_params;
 }

 同时附上一个去掉index.php的规则

location / {
      if (!-e $request_filename){
           rewrite ^/(.*)$ /index.php/$1 last;
      }
}


内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://sulao.cn/post/197.html

我要评论

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。