您的位置:首页 > 运维架构 > Nginx

thinkphp在Nginx下使用PATHINFO模式显示no input file specified的解决方法

2017-09-20 14:06 661 查看
因为项目原因可能大家会需要用到pathinfo模式。

百度到的方法基本都是在Nginx的location区用如下代码解决!

location ~ [^/]\.php(/|$) {                                 #PHP-FPM配置段
#fastcgi_pass remote_php_ip:9000;
fastcgi_pass unix:/dev/shm/php-cgi.sock;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_param PATH_INFO $fastcgi_path_info; #add
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}


此方法当你做了伪静态的时候,是可以正常使用的。就是假设后缀改成了html/aspx等等等等!

但是如果后缀保持php 又没有隐藏掉中间的index.php的时候

例如:
http://www.www.com/index.php/Admin/Admin/index.php
会报"no input file specified"

解决方法如下:

将以上的
fastcgi_split_path_info ^(.+\.php)(.*)$;
改成
fastcgi_split_path_info ^(.+\.php)(.*)\.php$;
即可解决

附隐藏index.php的方法

location / {
root html;
index index.php index.html index.htm;
if (!-e $request_filename) {
###一级目录下
#rewrite ^/(.*)$ /index.php/$1 last;
###域名下的二级目录
rewrite ^/tp5/(.*)$ /tp5/index.php/$1 last;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: