美文网首页
vue-cli3打包后上传服务器,浏览器刷新报nginx 404

vue-cli3打包后上传服务器,浏览器刷新报nginx 404

作者: 好一只帅卤蛋 | 来源:发表于2020-04-24 15:56 被阅读0次

项目完成之后,npm run build打包上传服务器,从页面正常跳转没有问题,一刷新就会发现vue项目会报nginx404的报错。

84a4d55a68dd24fb09ca0a37b50b140.jpg
解决方案如下,配置nginx
   location / {

    root   /root/pc;

 if ($http_user_agent ~* "(mobile|nokia|iphone|ipad|android|samsung|htc|blackberry)") {
            root  /root/phone;
     }
        index  index.html index.htm;
         #核心
        try_files $uri $uri/ @router;
     }
    #核心
     location @router {
         rewrite ^.*$ /index.html last;
     }
    
    #核心
    error_page  404              /index.html; 

相关文章

网友评论

      本文标题:vue-cli3打包后上传服务器,浏览器刷新报nginx 404

      本文链接:https://www.haomeiwen.com/subject/otmfwhtx.html