除了首页能访问,其他路由跳转都是Not Found,然后在域名后面加index.php就能访问,比如http://localhost:81/index.php/admin/,这样就能访问,去掉index.php就不行。
解决方法:
配置中隐藏掉index.php即可
打开nginx的配置文件
server {
listen 81;
server_name www.gohosts.com gohosts.com;
root "F:\PHPTutorial\WWW\LvRenJiaJi";
location / {
index index.html index.htm index.php;
//加上这两句话
if (-e $request_filename) {
break;
}
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php/$1 last;
break;
}
}
location ~ \.php(.*)$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
}