Here are some often needed htaccess rewrite rules.

**Redirect a domain to another domain name
**To redirect traffic from the domain to the domain use

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

**Rewrite all domain names to one domain** If you have multiple domains pointing to your server and you want to redirect them all to the single domain name

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

**Rewrite a subfolder to a (sub)domain
**When you move a folder to a domain or subdomain, e.g. to, and want to redirect all traffic use this rule:

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

The rewrite condition RewriteCond %{HTTP_HOST} ! [NC] is only needed if your subfolder and subdomain have the same name as you will otherwise get an error message like “the webpage has resulted in too many redirects”.