在部署tp的时候,有时候点击所有链接,都只能跳转到主页,也不报任何错误。首先想到的是路由的重定向问题。逐个排查

1.首先在public入口文件夹内添加.htaccess文件

<IfModule mod_rewrite.c>
  Options +FollowSymlinks -Multiviews
  RewriteEngine On

  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L]
</IfModule>

一般原因都是在最后一行 index.php后面没有添加?号。

2.查看配置文件(通常这里的原因不大)注:此处转载。因为我第一种方法就ok了

server{
         listen      80;
         server_name www.XXXX.com;
         index index.php index.html index.htm;
          root  /var/www/didu;

         location ~ \.php  #原来这个里有“$” 去掉就ok
          {
            #fastcgi_pass  unix:/tmp/php-cgi.sock;
            fastcgi_pass  127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_split_path_info ^(.+\.php)(.*)$; #新加第一句
            fastcgi_param PATH_INFO $fastcgi_path_info;#新加第二句
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;#新加第三句
            include fastcgi.conf;
         }

          location / {
              try_files $uri $uri/ /index.php?$query_string;
        }
}
 

特别注释:我有次又遇到只跳主页问题,上面的配置都没有问题,但是还是没法解决。

费了好大一会,才发现,在入口文件index.php里面多加了绑定模块的语句。之前是为了添加不同的模块加的,栽在这个坑里了

tp5 只跳转主页问题,点击所有连接只跳转主页

 

相关文章: