Nginx规则重定向一个特定的server_name

时间:2017-07-25 00:29:18

标签: regex nginx url-rewriting

我有一个带有倍数server_name的nginx,需要重定向到https特定的server_name。

使用我的配置(如下),我收​​到错误 ERR_TOO_MANY_REDIRECTS

我的conf:

animateWithDuration:animations:

有人可以帮我解决吗?

1 个答案:

答案 0 :(得分:0)

我认为你做得很复杂。首先:If is evil:)

我认为你想做几件事:

  1. 删除www"前缀"
  2. /rio/lisboa:使用特定主机
  3. contoso.comcontoso.sapo.pt:使用特定目录
  4. contoso.sapo.pt:强制https
  5. 我会采取另一种方式:

    1. 使用serverserver_name www.contoso.comserver_name www.contoso.com.br的其他return 301 $scheme://...部分。
    2. 试试location /riolocation /lisboa!或者更好的解决方案是使用alias(我认为你的nginx服务器静态内容和/rio/pt-BR是服务器上的目录)。
    3. 使用server块!
    4. 再次在server块中! return 301 https://$host$request_uri;
    5. 我认为,如果您创建的小块不仅是具有许多ifrewrite的大块,那么维护和调试会更容易。

相关问题