Redirect 301 to another Domain using .htaccess

Sometimes you might have a situation where you have a hoster selling you a simple „webspace package“, who provides you a default domain like „“. And you do not want your site to be accessible through that domain. You can simply rewrite every Request using not your desired Domain with a htaccess rule like this:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !$ [NC]
RewriteRule ^(.*)$$1 [L,R=301] 

This just takes every Domain which does not match with „“ and changes it to „“.