V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
GGGG430
V2EX  ›  NGINX

nginx 配置的一个问题

  •  
  •   GGGG430 · 2023-02-21 14:04:57 +08:00 · 1058 次点击
    这是一个创建于 431 天前的主题,其中的信息可能已经有所发展或是发生改变。

    如题, 有一个 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 / {} 就很奇怪, 我的正则写的不对吗?

    4 条回复    2023-02-21 14:54:41 +08:00
    julyclyde
        1
    julyclyde  
       2023-02-21 14:08:25 +08:00
    你开 debug 级别日志看看
    296727
        2
    296727  
       2023-02-21 14:09:32 +08:00   ❤️ 1
    要把子类写到父类上边
    Seanfuck
        3
    Seanfuck  
       2023-02-21 14:15:40 +08:00
    location ~ ^/visu/ {} 试试
    CopyRight
        4
    CopyRight  
       2023-02-21 14:54:41 +08:00
    alias /opt/path2/visu/dist/;
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5721 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 02:40 · PVG 10:40 · LAX 19:40 · JFK 22:40
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.