lnmp1.3 thinkphp3.2 pathinfo 模式下 U方法生成错误
public function windex(){echoU('Index/getcode');die();
}
生成url /Home/index/windex.php/Home/Index/getcode.html
public function index(){
echoU('Index/getcode');die();
}
生成url /Home/index/index.php/Home/Index/getcode.html
php.ini cgi.fix_pathinfo=1;
虚拟主机里面也替换了
#include enable-php.conf;
include enable-php-pathinfo.conf;
其他配置文件没有改动 tp 的'URL_MODEL'=>1, 求指点
修改了ThinkPHP的框架入口文件
if(!defined('_PHP_FILE_')) {
if(IS_CGI) {
//CGI/FASTCGI模式下
$_temp= explode('.php',$_SERVER['PHP_SELF']);
// define('_PHP_FILE_', rtrim(str_replace($_SERVER['HTTP_HOST'],'',$_temp.'.php'),'/'));
define('_PHP_FILE_', rtrim($_SERVER['SCRIPT_NAME'],'/'));
}else {
define('_PHP_FILE_', rtrim($_SERVER['SCRIPT_NAME'],'/'));
}
}
就显示
模板不存在:./App/Home/View/Index/Index.html
回复 1# 的帖子
程序上我们不清楚开pathinfo不需要改cgi.fix_pathinfo
https://lnmp.org/faq/lnmp-vhost-add-howto.html#pathinfo
回复 3# 的帖子
我的配置按https://lnmp.org/faq/lnmp-vhost-add-howto.html#pathinfo这个配置后,变成入口文件ry.php后跟着就是控制器Index,然后是方法userlogin(http://www.fjcnhk.top/ry.php/Index/userlogin),正常的pathinfo是http://www.fjcnhk.top/ry.php/Ry/Index/userlogin ,少了Ry;然后用thinkphp的U方法就变成了 http://www.fjcnhk.top/Index/userlogin.php/Index/userlogin.html;
我的域名.conf的配置是
server {
listen 80;
server_namewww.fjcnhk.top;
root /www/thinkphp;
index index.php;
location ~ ^(.*)/.svn/ {
deny all;
}
error_page 500 502 503 504/50x.html;
location = /50x.html {
root html;
}
include enable-php-pathinfo.conf;#这里是看了你们的建议修改的
location / {
if (!-e $request_filename)
{
rewrite ^(.*)$ /index.php?s=/$1 last;
}
}
location ~ .php$ {
fastcgi_passunix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include pathinfo.conf;
include fastcgi.conf;
}
}
页:
[1]