【问题标题】:How redirect dynamic subdomain to a domain with uri如何使用 uri 将动态子域重定向到域
【发布时间】:2016-01-24 19:52:11
【问题描述】:

我有这种情况。我想以这种格式在 nginx 中重定向所有子域。

(profile_name).mydomain.com mydomain.com/profile/(profile_name)

如何在 nginx 中做到这一点?

谢谢。

【问题讨论】:

    标签: redirect nginx uri subdomain response


    【解决方案1】:

    您可以使用正则表达式 server 块。

    server {
        server_name ~^(?<name>.+)\.example\.com$;
        return 301 http://example.com/profile/$name$request_uri;
    }
    

    详情请见this document。

    【讨论】:

      猜你喜欢
      • 2013-02-09
      • 2017-04-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-19
      • 2021-09-09
      • 2012-04-01
      相关资源
      最近更新 更多