zoukankan      html  css  js  c++  java
  • nginx path_info问题解决

    问题:

    访问www.xxxx.com/index.php/api/xxxxxxxxx网址时,提示无法访问,找不到页面

    解决:

    第一次,是改了nginx.conf,不会报这个错误了,但还是没有用

    location ~ ^.+.php {
      (...)
      fastcgi_split_path_info ^((?U).+.php)(/?.+)$;
      fastcgi_param SCRIPT_FILENAME /path/to/php$fastcgi_script_name;
      fastcgi_param PATH_INFO $fastcgi_path_info;
      fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
      (...)
    }

    第二次,检查代码,发现在$_SERVER里找不到Path_info。需要在php.ini里配置几个选项,但有人说这样做不安全。
    cgi.force_redirect = 0
    cgi.fix_pathinfo=1
    fastcgi.impersonate = 1
    第三次,还是在nginx.conf里改了,给cgi传了path_info,问题解决(前提,关闭第二次在php.ini里改的内容)
            location ~ .php(.*)$  {
                root           html/N168_7.0;
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                include fastcgi_params;
                set $path_info "";
                set $real_script_name $fastcgi_script_name;
                if ($fastcgi_script_name ~ "^(.+?.php)(/.+)$") {
                    set $real_script_name $1;
                    set $path_info $2;
                }

                fastcgi_param  SCRIPT_FILENAME  $document_root$real_script_name;
                fastcgi_param  SCRIPT_NAME  $real_script_name;
                fastcgi_param  PATH_INFO  $path_info;
            }

    总结:ThinkPhp里面默认用了Path_info,所以你必须得配置,否则像一些特定路径就用不了

    参考来源:
    http://www.nginx.cn/426.html
    http://www.laruence.com/2009/11/13/1138.html
  • 相关阅读:
    cogs 1682. [HAOI2014]贴海报 WW
    cogs 2039. 树的统计
    cogs luogu [NOIP2011] 选择客栈
    cogs luogu 1804. [NOIP2014]联合权值 WD
    cogs luogu [NOIP2014]生活大爆炸版石头剪刀布
    leetcode[119]Pascal's Triangle II
    leetcode[120]Triangle
    leetcode[121]Best Time to Buy and Sell Stock
    leetcode[122]Best Time to Buy and Sell Stock II
    leetcode[123]Best Time to Buy and Sell Stock III
  • 原文地址:https://www.cnblogs.com/si812cn/p/4329001.html
Copyright © 2011-2022 走看看