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 @   全玉  阅读(579)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
历史上的今天:
2017-06-17 微信小程序页面跳转传参
点击右上角即可分享
微信分享提示