当前位置:网站首页 > 更多 > 编程开发 > 正文

[软件开发] 解决 Vue 在 History 模式部署在 Nginx 上刷新报 404 的问题

作者:CC下载站 日期:2019-12-27 00:00:00 浏览:51 分类:编程开发

教程适用于history模式,假设域名假设为:auauz.net

原配置

server {
    listen 80;
    server_name auauz.net;
    root /www/wwwroot/eladmin-web/dist;
    index index.html;
    error_page 404 /index.html;
}

修改如下

server {

    listen 80;
    server_name auauz.net;
    
    location / {
        root /www/wwwroot/eladmin-web/dist;
        try_files $uri $uri/ @router;
        index index.html;
    }
    
    location @router {
        rewrite ^.*$ /index.html last;
    }
}
您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯