【问题标题】:nginx how to redirect app.sub.domain to app.domainnginx 如何将 app.sub.domain 重定向到 app.domain
【发布时间】:2015-02-10 16:43:48
【问题描述】:

能否请您建议如何配置 nginx 重定向:

*.sub.domain.com -> *.domain.com

app1.sub.domain.com -> app1.domain.com

app2.sub.domain.com -> app2.domain.com

...

这就是我想要做的:

{
    listen       80;
    server_name ~^(\w+)\.sub\.domain\.com$;
    return 301 $scheme://$app.domain.com$request_uri;
}  

在 app1.sub.domain.com 重定向后得到:

Location: http://.domain.com/  

【问题讨论】:

  • 请付出一些努力。转到 nxinx.org 上的官方文档,阅读重定向参数,如果您仍然需要帮助,请使用您尝试过的配置更新您的问题。
  • 更新的问题似乎是重复的:serverfault.com/questions/583944/…

标签: regex redirect nginx


【解决方案1】:

它不适用于我在带有 nginx 1.6.2 的 AWS Linux 上 但它在带有 nginx 1.4.6 的 Ubuntu 上运行良好

【讨论】:

    猜你喜欢
    • 2022-01-11
    • 2018-09-21
    • 2022-08-14
    • 1970-01-01
    • 2015-10-19
    • 2017-09-24
    • 2011-04-23
    • 2016-04-05
    相关资源
    最近更新 更多