Linux and Apache

Rewrite based on domain

Recently I needed to redirect traffic when the domain was NOT www.website.co.nz. This is often handy if you have several domains hinged off one virtual host.

RewriteCond %{HTTP_HOST} !^www\.website\.co\.nz$ [NC]
RewriteRule .* http://%{HTTP_HOST} [R=301,L]