【问题标题】:Nginx rule for redirection error重定向错误的 Nginx 规则
【发布时间】:2016-06-15 05:01:06
【问题描述】:

我需要为特定的 url 设置重定向规则 - 我正在使用 NGINX。

基本上是这样的:

http://example.com/ --> http://example.com/maps

我正在尝试:

location / {
proxy_pass http://maps-testmk;
include /etc/nginx/proxy_params;
return 301 http://maps-testmk.mgr.ru/maps;
}

}

但我有 - 500 错误

【问题讨论】:

    标签: redirect nginx


    【解决方案1】:

    可能是这样的:

    location = / {
        return 301 http://maps-testmk.mgr.ru/maps;
    }
    location / {
        proxy_pass http://maps-testmk;
        include /etc/nginx/proxy_params;
    }
    

    【讨论】:

      【解决方案2】:

      您可以使用location = 语法来识别特定的网址。例如:

      location = / {
          return 301 /maps;
      }
      
      location / {
          proxy_pass http://maps-testmk;
          include /etc/nginx/proxy_params;
      }
      

      只有 URI / 被重定向到 /maps。所有其他 URI(包括 /maps)都向上游发送。

      详情请见this document

      【讨论】:

        猜你喜欢
        • 2015-12-22
        • 2011-08-24
        • 1970-01-01
        • 2017-02-04
        • 1970-01-01
        • 2016-05-20
        • 2015-05-18
        • 2016-07-01
        • 2018-12-20
        相关资源
        最近更新 更多