laravel项目上传lnmp环境404问题解决(laravel路由隐藏index.php)

问题现象

只有根目录下的独立文件可访问,通过路由的控制器访问均提示404

解决办法

修改nginx配置文件
[root@lnmp wdrmyyHRP]# vi /usr/local/nginx/conf/nginx.conf
在location中添加try_files $uri $uri/ /index.php?$query_string;

    location / {
            root   /data/www/wdrmyyHRP/public;
            index  index.html index.htm index.php;
            try_files $uri $uri/ /index.php?$query_string;

         }

对于设置配置文件包含vhost/*.conf的用户请在对应的.conf文件中的location 中添加。

设置完成记得重启服务。

[root@lnmp wdrmyyHRP]# /usr/local/nginx/sbin/nginx -s reload


END

猜你喜欢

转载自blog.csdn.net/Qcg0223/article/details/104356693