欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

nginx支持thinkphp的pathinfo解决方法

程序员文章站 2022-06-15 08:52:22
...
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 {
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支持thinkphp的pathinfo解决方法

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。

相关文章

相关视频