server { . . . server_name www.domain1.com; rewrite ^/(.*)$ http://www.domain2.com/$1 redirect; . . . } server { . . . server_name www.domain2.com; . . . }