How to redirect to a different domain using NGINX?

前端 未结 8 872
旧时难觅i
旧时难觅i 2020-12-02 07:10

How can I redirect mydomain.com and any subdomain *.mydomain.com to www.adifferentdomain.com using NGINX?

8条回答
  •  天命终不由人
    2020-12-02 08:08

    If you would like to redirect requests for "domain1.com" to "domain2.com", you could create a server block that looks like this:

    server {
        listen 80;
        server_name domain1.com;
        return 301 $scheme://domain2.com$request_uri;
    }
    

提交回复
热议问题