【问题标题】:nginx rewrite exclude subdomainsnginx 重写排除子域
【发布时间】:2015-01-20 20:01:38
【问题描述】:

我需要重定向:

http://*.example.com/list/

http://demo.example.com/list/

从重写规则链接中排除:

xxx.example.com/list/
yyy.example.com/list/
zzz.example.com/list/

这应该是一个正则表达式,对吧?.. 但我是这里的新手。提前 Tnx。

【问题讨论】:

    标签: regex nginx rewrite


    【解决方案1】:
    server {
        listen 80;
        server_name .example.com;
    
        location /list/ {
            if ($host !~ ^(xxx|yyy|zzz)\.example\.com) {
                return 301 http://demo.example.com/list/;
            }
            # ....
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-01-30
      • 1970-01-01
      • 2011-09-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-04
      相关资源
      最近更新 更多