nginx 域名跳转

if ($host != 'www.test.com') {
      rewrite ^/(.*)$ http://www.test.com/$1 permanent;
}

地址http://www.oschina.net/question/170653_46608

2.Nginx虚拟主机多server_name的顺序问题

if ($host != $server_name) {
    rewrite ^/(.*)$ http://$server_name/$1 permanent;
}

nginx 配置中找到 fastcgi_param 部分,修改

fastcgi_param  SERVER_NAME    $server_name;
fastcgi_param  SERVER_NAME    $host;
详细地址 http://blog.s135.com/post/382

3.Nginx 根据 server_name 跳转 ,根域名跳转到 www域名

server_name  www.lanmps.com alias lanmps.com w.net;
if ($host != $server_name) {
    rewrite ^/(.*)$ http://$server_name/$1 permanent;
}

你可能感兴趣的:(nginx)