解决laravel项目只能访问index.php根目录,其他目录报404错误

一步一步的排查问题,首先,肯定是服务器配置出了问题,和代码无关。

于是去看nginx.conf,在网上查了很多关于这个问题的解决办法,说的大致都一样,就是在

location / {
    root D:/phpstudy_pro/WWW/Unifiedtransform/public/;
    index index.html index.htm index.php;            
    gzip_static on;
    if (!-e $request_filename){  
        rewrite ^/(.*) /index.php last;  
    } 
}

插入

try_files $uri $uri/ /index.php?$query_string;

但是还是没有解决问题,后来往下看,看到这里引用了 vhost/*.conf

所以要在对应的vhost文件下的localhost /{}中加入这行代码,就像这样:

 

 

 

 

 

 

posted @ 2020-04-21 15:08  千逸山水  阅读(1375)  评论(0)    收藏  举报