如何使用NGINX重定向到其他域? [英] How to redirect to a different domain using NGINX?
本文介绍了如何使用NGINX重定向到其他域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用NGINX将mydomain.com
和任何子域*.mydomain.com
重定向到www.adifferentdomain.com
?
How can I redirect mydomain.com
and any subdomain *.mydomain.com
to www.adifferentdomain.com
using NGINX?
推荐答案
server_name 支持使用进行后缀匹配. mydomain.com语法:
server_name supports suffix matches using .mydomain.com syntax:
server {
server_name .mydomain.com;
rewrite ^ http://www.adifferentdomain.com$request_uri? permanent;
}
或任何0.9.1或更高版本上:
or on any version 0.9.1 or higher:
server {
server_name .mydomain.com;
return 301 http://www.adifferentdomain.com$request_uri;
}
这篇关于如何使用NGINX重定向到其他域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文