server {
listen ;
server_name *.olddomain.com;
if ( $http_host ~* "^(.*?)\.olddomain\.com$"){
set $domain $;
}
rewrite ^/(.*) http://$domain.newdomain.com/$1 permanent;
}
server {
listen ;
server_name *.olddomain.com;
if ( $http_host ~* "^(.*?)\.olddomain\.com$"){
set $domain $;
}
rewrite ^/(.*) http://$domain.newdomain.com/$1 permanent;
}