1.按域名进行跳转重定向
server
{
listen 80;
server_name example.com;
rewrite ^/(.*)$ http://www.example.com/$1 permanent;
}
2.按多域名情况下针对特定域名进行跳转重定向
server
{
listen 80;
server_name example.com example1.com;
if ($host = 'example1.com' ) {
rewrite ^/(.*)$ http://example.com/$1 permanent;
}
}