nginx实现301重定向设定

方法一:
server {
server_name www.jefflei.com jefflei.com ;
if ($host != 'www.jefflei.com' ) {
rewrite ^/(.*)$ http://www.jefflei.com/$1 permanent;
}
...
}

方法二:
server {
server_name jefflei.com;
rewrite ^/(.*) http://www.jefflei.com/$1 permanent;
}

redirect – 返回临时重定向的HTTP状态302
permanent – 返回永久重定向的HTTP状态301