vue history nginx 刷新404

2022-08-19  本文已影响0人  漫画三毛
  1. 二级目录配置
    location ^~ /mobile {
            root /www/wwwroot/;
            try_files $uri $uri/ @router;
    }
    
    #对应上面的@router,主要原因是路由的路径资源并不是一个真实的路径,所以无法找到具体的文件
    #因此需要rewrite到index.html中,然后交给路由在处理请求资源
    location @router {
        rewrite ^.*$ /mobile/index.html last;
    }
注意:和一级目录不一样的地方是 @router rewrite 需要指定目录下的index.html
上一篇 下一篇

猜你喜欢

热点阅读