从旧域重定向到新域

时间:2012-11-07 00:29:34

标签: nginx

如何在nginx上设置重定向? 我需要实现的是将旧域重定向到作为服务器名称的新域。 尝试使用重写我遇到了问题因为有了它我需要将旧域和新域设置为服务器名称。

2 个答案:

答案 0 :(得分:1)

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

server {
    server_name new.example.org;


    location / {
        ...
    }


}

答案 1 :(得分:0)

尝试在旧主机名的服务器块配置中使用“proxy_pass example.newdomain.com:8080”指令。