问题:
访问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 = 0cgi.fix_pathinfo=1fastcgi.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,所以你必须得配置,否则像一些特定路径就用不了
时间: 2024-10-07 19:32:42