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

请问如何设置 rewrite,才能使得 Nginx 二级目录如果是大写跳转为小写?

  •  
  •   ecosky · 2020-05-25 16:19:53 +08:00 · 1702 次点击
    这是一个创建于 1403 天前的主题,其中的信息可能已经有所发展或是发生改变。
    现在有个场景需求,列如: https://www.test.com/TeSt/AA/BB 跳转为 https://www.test.com/test/AA/BB
    我这样操作不行,
    location /test {
    proxy_pass http://127.0.0.1:8080;
    }
    location ~* /test/ {
    rewrite .* /test/ last;
    }

    网上查询看都是直接用 lua 直接整个 url 都转为小写了,但我只需要这个二级目录转为小写,请问如何操作呢?
    1 条回复    2020-06-01 15:00:34 +08:00
    rrfeng
        1
    rrfeng  
       2020-06-01 15:00:34 +08:00
    rewrite /TeST/(.*) /test/$1;
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5174 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 09:41 · PVG 17:41 · LAX 02:41 · JFK 05:41
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.