【发布时间】:2016-01-24 19:52:11
【问题描述】:
我有这种情况。我想以这种格式在 nginx 中重定向所有子域。
(profile_name).mydomain.com mydomain.com/profile/(profile_name)
如何在 nginx 中做到这一点?
谢谢。
【问题讨论】:
标签: redirect nginx uri subdomain response
我有这种情况。我想以这种格式在 nginx 中重定向所有子域。
(profile_name).mydomain.com mydomain.com/profile/(profile_name)
如何在 nginx 中做到这一点?
谢谢。
【问题讨论】:
标签: redirect nginx uri subdomain response
您可以使用正则表达式 server 块。
server {
server_name ~^(?<name>.+)\.example\.com$;
return 301 http://example.com/profile/$name$request_uri;
}
详情请见this document。
【讨论】: