>  기사  >  백엔드 개발  >  nginx支持thinkphp的pathinfo解决方法

nginx支持thinkphp的pathinfo解决方法

WBOY
WBOY원래의
2016-06-13 12:08:441022검색

nginx支持thinkphp的pathinfo
现在发现问题有两个:
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:

RewriteEngine on
RewriteRule ^(.*)$ index.php/$1 last


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"

------解决思路----------------------

server {<br />       listen  80;<br />       server_name     www.phpno.com;<br />       root /home/www/www_phpno_com/admin_wwwroot;<br />       access_log off;<br />       error_page 404  /404.html;<br />       location /404.html {<br />               root /home/www/www_phpno_com/admin_wwwroot;<br />       }<br />       location /{<br />               index index.html index.htm index.php;<br />               if (-e $request_filename) {<br />                       break;<br />               }<br />               if (!-e $request_filename) {<br />                       rewrite ^/(.*)$ /index.php/$1 last;<br />                       break;<br />               }<br />       }<br /> <br />       location ~ .+\.php($<br><font color='#FF8000'>------解决思路----------------------</font><br>/) {<br />           root           /home/www/www_phpno_com/admin_wwwroot;<br />           fastcgi_index index.php;<br />           fastcgi_split_path_info ^(.+\.php)(.*)$;<br />           fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;<br />           fastcgi_param   PATH_INFO               $fastcgi_path_info;<br />           fastcgi_param   PATH_TRANSLATED $document_root$fastcgi_path_info;<br />           fastcgi_pass   127.0.0.1:9000;<br />           include        fastcgi_params;<br />       }<br />   }
自己对比一下

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.