解决访问任何路径都是首页问题
1.修改nginx.conf配置
location ~ \.php {
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_params;
}
location / { #去掉$
if ( -f $request_filename) {
break;
}
if ( !-e $request_filename) {
rewrite ^(.*)$ /index.php/$1 last;
break;
}
#新增
try_files $uri $uri/ /index.php?$query_string;
}
2.修改apache的.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>
3.修改项目的config.php中的pathinfo_fetch
修改项目配置 config.php 中的 pathinfo_fetch 在末尾添加上 REQUEST_URI
// 兼容PATH_INFO获取’pathinfo_fetch’ => [‘ORIG_PATH_INFO’, ‘REDIRECT_PATH_INFO’, ‘REDIRECT_URL’, ‘REQUEST_URI’],
4.修改.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>