Nginx上設置301和302跳轉

301跳轉(由abc.com跳轉到def.com):

server {
listen 80;
server_name abc.com;
rewrite ^/(.*) http://def.com/$1 permanent;
access_log off;
}

302跳轉(由abc.com跳轉到def.com):

server {
listen 80;
server_name abc.com;
rewrite ^/(.*) http://def.com/$1 redirect;
access_log off;
}