NginxHttpRewriteModule Documentation

# redirects arbitrary subdomain (some.random.sub.example.com) to (some.random.sub.example.org)
if ($host ~* “^([^.]+(\.[^.]+)*)\.example.com$”){
set $subd $1;
rewrite ^(.*)$ http://$subd.example.org$1 permanent;
break;
}

# Simply redirects example.com to example.org
if ($host ~* “^example.com$”){
rewrite ^(.*)$ http://example.org$1 permanent;
break;
}

Advertisements