在部署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裏面多加了綁定模塊的語句。之前是爲了添加不同的模塊加的,栽在這個坑裏了