tp5伺服器訪問只顯示首頁解決方案(linux)
阿新 • • 發佈:2019-01-28
首先檢視nginx配置檔案
server { listen 80; server_name api.cloudworkshop.cn; access_log /app/logs/nginx/api.log; error_log /app/logs/nginx/api_error.log; set $root /data/ygc/public; location ~ .*\.(gif|jpg|jpeg|bmp|png|ico|txt|js|css)$ { root $root; } location / { root $root; index index.html index.php; if ( -f $request_filename) { break; } if ( !-e $request_filename) { rewrite ^(.*)$ /index.php/$1 last; break; } } location ~ .+\.php($|/) { fastcgi_pass unix:/run/php/php7.0-fpm.sock; fastcgi_split_path_info ^((?U).+.php)(/?.+)$; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $root$fastcgi_script_name; include fastcgi_params; } }
如何還未修改成功,就在.htaccess裡面配置
<IfModule mod_rewrite.c>
Options +FollowSymlinks -Multiviews
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?s=$1 [QSA,PT,L]
</IfModule>
若還未奏效,試圖改變訪問方法看看 http://xxx.xxx.cn/index.php?s=模組名/控制器名/方法名
如果訪問成功了,則修改config.php 的配置檔案,配置開啟pathinfo模式
'pathinfo_fetch' => ['ORIG_PATH_INFO', 'REDIRECT_PATH_INFO', 'REDIRECT_URL', 'REQUEST_URI'],
也就是在'pathinfo_fetch'選項裡面加入'REQUEST_URL'就可以了