【问题标题】:Wildcard subdomain rewrites in nginxnginx 中的通配符子域重写
【发布时间】:2013-09-30 02:42:18
【问题描述】:

我正在尝试让 nginx 重写

http://subdomain.example.com

http://example.com?username=subdomain

而且没有任何运气。重要的是用户在浏览器中看到前一个 URl,但 nginx 将其解释为后一个 URL。

提前感谢您的帮助。

【问题讨论】:

    标签: nginx rewrite subdomain wildcard


    【解决方案1】:

    nginx配置:

    server {
      server_name   ~^(?<subdomain>.+?)\.example\.com$;
      rewrite ^ /?username=$subdomain redirect;
    }
    

    【讨论】:

      猜你喜欢
      • 2012-08-09
      • 2014-06-11
      • 2014-12-29
      • 1970-01-01
      • 2013-02-22
      • 2023-03-13
      • 2014-06-09
      • 2011-01-30
      相关资源
      最近更新 更多