您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

nginx支持thinkphp的pathinfo

2025/8/5 11:17:16发布22次查看
现在发现问题有两个:
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
回复讨论(解决方案) 这会有把 location ~ \.php$ {  改成 location ~ \.php/?.*$ { 和  location ~ .+\.php($|/) {  ,改完后nginx -s reload后发现还是没用。
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; } }

自己对比一下
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
我现在的配置文件是这样的:
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; }
配置如上。。。刚才重启了下电脑。。。好了。。。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product