nginx支持thinkphp的pathinfo

u012914916 2014-10-27 01:58:16
现在发现问题有两个:
1 不支持PATHINFO。
localhost/?m=login可以访问,localhost/login不能访问。
2 THINKPHP的U方法生成的地址错误。
U('login/index')生成的地址是/login-index.html。

nginx配置文件:
location ~ \.php$ {
root D:/AppServ/www;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

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_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info;

include fastcgi_params;
}

.htacess:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(.*)$ index.php/$1 last
</IfModule>

nginx错误日志:
2014/10/27 13:54:42 [error] 5404#5668: *107 CreateFile() "D:/AppServ/www/login" failed (2: The system cannot find the file specified), client: 127.0.0.1, server: localhost, request: "GET /login HTTP/1.1", host: "localhost"
...全文
263 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
楼主 你的问题解决了吗?是怎么解决的,我现在也遇到这个问题。
u012914916 2014-10-27
  • 打赏
  • 举报
回复
配置如上。。。刚才重启了下电脑。。。好了。。。
u012914916 2014-10-27
  • 打赏
  • 举报
回复
我现在的配置文件是这样的:

location / {
            root   D:/AppServ/www; 
            index  index.php index.html index.htm;
			if (-e $request_filename) {
                       break;
               }
               if (!-e $request_filename) {
                       rewrite ^/(.*)$ /index.php/$1 last;
                       break;
               }
        }
location ~ .+\.php($|/) {
            root           D:/AppServ/www;
            fastcgi_index  index.php;
            fastcgi_split_path_info ^(.+\.php)(.*)$;
			fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
			fastcgi_param   PATH_INFO               $fastcgi_path_info;
			fastcgi_param   PATH_TRANSLATED $document_root$fastcgi_path_info;
            fastcgi_pass   127.0.0.1:9000;
			include        fastcgi_params;
        }
u012914916 2014-10-27
  • 打赏
  • 举报
回复
引用 2 楼 xuzuning 的回复:
server {
       listen  80;
       server_name     www.phpno.com;
       root /home/www/www_phpno_com/admin_wwwroot;
       access_log off;
       error_page 404  /404.html;
       location /404.html {
               root /home/www/www_phpno_com/admin_wwwroot;
       }
       location /{
               index index.html index.htm index.php;
               if (-e $request_filename) {
                       break;
               }
               if (!-e $request_filename) {
                       rewrite ^/(.*)$ /index.php/$1 last;
                       break;
               }
       }
 
       location ~ .+\.php($|/) {
           root           /home/www/www_phpno_com/admin_wwwroot;
           fastcgi_index index.php;
           fastcgi_split_path_info ^(.+\.php)(.*)$;
           fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
           fastcgi_param   PATH_INFO               $fastcgi_path_info;
           fastcgi_param   PATH_TRANSLATED $document_root$fastcgi_path_info;
           fastcgi_pass   127.0.0.1:9000;
           include        fastcgi_params;
       }
   }
自己对比一下
感谢热心的徐版主。 我按您贴出的配置改了,除了路径。 但还是不行。我的nginx版本是1.6.2。错误日志还是 CreateFile() "D:/AppServ/www/login" failed (2: The system cannot find the file specified), client: 127.0.0.1, server: localhost, request: "GET /login HTTP/1.1", host: "localhost"
xuzuning 2014-10-27
  • 打赏
  • 举报
回复
server {
       listen  80;
       server_name     www.phpno.com;
       root /home/www/www_phpno_com/admin_wwwroot;
       access_log off;
       error_page 404  /404.html;
       location /404.html {
               root /home/www/www_phpno_com/admin_wwwroot;
       }
       location /{
               index index.html index.htm index.php;
               if (-e $request_filename) {
                       break;
               }
               if (!-e $request_filename) {
                       rewrite ^/(.*)$ /index.php/$1 last;
                       break;
               }
       }
 
       location ~ .+\.php($|/) {
           root           /home/www/www_phpno_com/admin_wwwroot;
           fastcgi_index index.php;
           fastcgi_split_path_info ^(.+\.php)(.*)$;
           fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
           fastcgi_param   PATH_INFO               $fastcgi_path_info;
           fastcgi_param   PATH_TRANSLATED $document_root$fastcgi_path_info;
           fastcgi_pass   127.0.0.1:9000;
           include        fastcgi_params;
       }
   }
自己对比一下
u012914916 2014-10-27
  • 打赏
  • 举报
回复
这会有把 location ~ \.php$ { 改成 location ~ \.php/?.*$ { 和 location ~ .+\.php($|/) { ,改完后nginx -s reload后发现还是没用。

20,398

社区成员

发帖
与我相关
我的任务
社区描述
“超文本预处理器”,是在服务器端执行的脚本语言,尤其适用于Web开发并可嵌入HTML中。PHP语法利用了C、Java和Perl,该语言的主要目标是允许web开发人员快速编写动态网页。
phpphpstorm 技术论坛(原bbs)
社区管理员
  • 开源资源社区
  • phpstory
  • xuzuning
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧