nginx单页应用配置

1. 直接对指定路由配置重写
location ~* html {
    rewrite .* /index.html break;
}
location /login {
    rewrite .* /index.html break;
}
location /admin {
    rewrite .* /index.html break;
}
2. 通用单页路由指定
location / {
    try_files $uri $uri/ /index.html index.htm;
}

或者

location / {
    try_files $uri $uri/ @rewrites;  
 }
location @rewrites {
     rewrite ^(.+)$ /index.html last;
}

 

 

参考:https://developer.jdcloud.com/article/2105
posted @ 2022-06-17 09:55  全玉  阅读(532)  评论(0编辑  收藏  举报