vue-router history模式下,刷新页面404问题

搜索了很多前辈的解决方案一直没有解决问题,配置类似如下
`

    location / {
        root   html;
        index  index.html index.htm; 
        try_files $uri $uri/ /index.html;
    }

`
总是会报500。
最后研究才发现,前辈得解决案例是nginx下部署一个前端项目,而我这边的情况是一个nginx下有多个前端项目,稍微调整一下路径后,问题迎刃而解。
具体方法如下(只需要修改nginx的nginx.conf文件,此修改方式不影响其他前端项目的路由默认,只处理本人得项目):
`
server {

    listen       8090;
    server_name  localhost;

    #charset koi8-r;

    #access_log  logs/host.access.log  main;

    location / {
        root   html;
        index  index.html index.htm; 
    }
    
    #解决路由history模式下,刷新页面404问题
    location /webName/ {
        root   html;
        index  index.html index.htm; 
          try_files $uri $uri/ /webName/index.html;
    }
    ....

}
`

你可能感兴趣的:(nginx,vue-router,vue.js)