如何使用 uri 将动态子域重定向到域
How redirect dynamic subdomain to a domain with uri
我有这个场景。我想在 nginx 中以这种格式重定向所有子域。
(profile_name).mydomain.com
我的域。com/profile/(profile_name)
我如何在 nginx 中执行此操作?
谢谢。
您可以使用正则表达式 server
块。
server {
server_name ~^(?<name>.+)\.example\.com$;
return 301 http://example.com/profile/$name$request_uri;
}
详情见this document。
我有这个场景。我想在 nginx 中以这种格式重定向所有子域。
(profile_name).mydomain.com 我的域。com/profile/(profile_name)
我如何在 nginx 中执行此操作?
谢谢。
您可以使用正则表达式 server
块。
server {
server_name ~^(?<name>.+)\.example\.com$;
return 301 http://example.com/profile/$name$request_uri;
}
详情见this document。