【问题标题】:Nginx rule for redirectionNginx 重定向规则
【发布时间】:2015-12-22 07:01:07
【问题描述】:

我在 Nginx 中有以下规则将特定 url 重定向到新 url

location /customer/my_info {
  proxy_pass http://example.com/abc;
}

这很好用。我还有另一个 url,我不想被重定向,但它正在被重定向。

/customer/my_info_verify

需要添加什么规则才能只重定向完全匹配的 url?

【问题讨论】:

    标签: ubuntu nginx webserver


    【解决方案1】:

    使用 = 修饰符定义 URI 和位置的精确匹配。如果找到完全匹配,则搜索终止。

    location = /customer/my_info {
      proxy_pass http://example.com/abc;
    }
    

    来源:http://nginx.org/en/docs/http/ngx_http_core_module.html#location

    【讨论】:

    • 请记住,这与 /customer/my_info/ 不匹配。如果你也想匹配那个 URL,我会使用这样的正则表达式匹配:location ~* ^/customer/my_info/?$
    猜你喜欢
    • 2011-08-24
    • 1970-01-01
    • 2017-02-04
    • 1970-01-01
    • 2018-12-20
    • 2016-06-15
    • 2016-05-20
    • 2015-05-17
    • 2019-10-23
    相关资源
    最近更新 更多