nginx 配置的一个问题

2023-02-21 14:04:57 +08:00
 GGGG430

如题, 有一个 url 为 https://xx.net/visu,

nginx 配置为 location / { root /opt/path2/admin/dist; index index.html; }

location ~^/(visu*) { root /opt/path2/visu/dist/; index index.html; }

此时能正常访问, 但是前端路由会跳转成 https://xx.net/visu/inspection 此时上面的 location 会匹配到 localtion / {} 就很奇怪, 我的正则写的不对吗?

1080 次点击
所在节点    NGINX
4 条回复
julyclyde
2023-02-21 14:08:25 +08:00
你开 debug 级别日志看看
296727
2023-02-21 14:09:32 +08:00
要把子类写到父类上边
Seanfuck
2023-02-21 14:15:40 +08:00
location ~ ^/visu/ {} 试试
CopyRight
2023-02-21 14:54:41 +08:00
alias /opt/path2/visu/dist/;

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/917913

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX