Marco C
Marco C

Reputation: 3213

Redirect from old domain to new domain

How is it possible set a redirection on nginx? The thing that I need to achieve is to redirect an old domain to the new domain that is the server name. Trying to use rewrite I am getting problems because with it I need to set as server name the old domain and the new one on the rewrite.

Upvotes: 0

Views: 598

Answers (2)

VBart
VBart

Reputation: 15110

server {
    server_name old.example.com;
    return 301 http://new.example.org/;
}

server {
    server_name new.example.org;


    location / {
        ...
    }


}

Upvotes: 1

Ziaunys
Ziaunys

Reputation: 76

Try using the "proxy_pass example.newdomain.com:8080" directive in a server block config of the old host name.

Upvotes: 0

Related Questions