跳到正文
测试源码分享
返回文章列表

vue框架下部署上线后刷新报404问题解决方案

705 次阅读约 1 分钟读完

nginx配置

text
location / {
  try_files $uri $uri/ /index.html;
}

vue history模式下nginx配置

text
在宝塔的网站设置中修改
server {
         listen 80;

         server_name testwx.wangshibo.com;
         root /Data/app/xqsj_wx/dist;
         index index.html;
         access_log /var/log/testwx.log main;

	## 注意从这里开始
         location / {
             try_files $uri $uri/ @router;
             index index.html;
         }

        location @router {
            rewrite ^.*$ /index.html last;
        }
 }