【问题标题】:nginx rewrite uppercase to lowercase letters in a rewrite rulenginx在重写规则中将大写字母重写为小写字母
【发布时间】:2020-09-11 20:58:00
【问题描述】:

我想像这样重写 url: www.example.com/TeSt/AAA/BBBB ------> www.example.com/test/AAA/BBB

我是这样做的,但是还没做:

location /test {
    proxy_pass http://127.0.0.1:8080;
}
location ~* /test/ {
    rewrite .* /test/ last;
}

【问题讨论】:

    标签: nginx url-rewriting


    【解决方案1】:

    Nginx 将在前缀location 上选择匹配的正则表达式location,除非使用^~ 运算符。有关详细信息,请参阅this document

    rewrite 表达式需要不区分大小写,并且需要捕获 URI 的剩余部分。

    例如:

    location ^~ /test {
        proxy_pass http://127.0.0.1:8080;
    }
    location ~* /test {
        rewrite (?i)^/test(.*)$ /test$1 last;
    }
    

    【讨论】:

    猜你喜欢
    • 2011-04-09
    • 1970-01-01
    • 1970-01-01
    • 2013-02-04
    • 2015-07-28
    • 1970-01-01
    • 2021-10-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多