[英]Nginx redirect to another domain with diff TLD
So, I have two domains with diff TLDs.因此,我有两个具有不同 TLD 的域。
Like example.com and example.org比如 example.com 和 example.org
I want to set Nginx redirect so that I can redirect.com to.org我想设置 Nginx 重定向,这样我就可以将 com 重定向到.org
Like below:像下面这样:
example.com => example.org
www.example.com => www.example.org
anything.to.any.levels.example.com => anything.to.any.levels.example.org
example.com/anything/to/any/levels => example.org/anything/to/any/levels
anything.to.any.levels.example.com/anything/to/any/levels => anything.to.any.levels.example.org/anything/to/any/levels
You can use a regular expression with the server_name
directive to capture the particular subdomain.您可以使用带有
server_name
指令的正则表达式来捕获特定的子域。 See this document for details.有关详细信息,请参阅此文档。
For example:例如:
server {
listen 80;
listen 443 ssl;
server_name ~^(?<subdomain>.*\.)?example\.com$;
ssl_certificate ...;
ssl_certificate_key ...;
return 301 $scheme://${subdomain}example.org$request_uri;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.