Redirect a complete domain to a new domain with .htaccess

Instructions: Battery replacement for the Ion Audio Blockrocker

Icon instructionsWhen a domain move is pending, you often want to keep the old domain active and redirect the visitors who come across it to the new domain. In order to make this SEO-friendly, one uses a forwarding that is implemented with the htaccess file that is stored in the main directory of the domain. The file must be called ".htaccess" and have the following text content:


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

In order to realize this, both domains do not have to point to different directories. Even if both domains refer to the same directory with the same data, the redirect in the .htaccess file can refer the visitors (and also the search engine bots) to the new domain.

Correct SEO redirect for Google or links?

Through the redirection, search engines such as Google also receive feedback that the old domain has moved permanently (hence the HTTP status 301) to the new domain. Backlinks that refer to the old domain are "bent" over to the new one and do not lose their effect on the Google rankings. According to the SEO rumor mill, however, they are losing a bit of "power", so it is advisable to write to the webmasters of the strongest domains and ask them to correct the link. Incidentally, search engine optimizers like me also take on such work. ;-)

Redirection with https

If you want to change the protocol in addition to the domain because the domain has been converted to SSL encryption, then you can address the new domain directly via https in the above code. The code then looks like this:

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

If the domains do not change and you are only looking for a code or instructions for converting your WordPress blog from http: // to https: //, then you will find it here is the appropriate article to.


Did you like the article and did the instructions on the blog help you? Then I would be happy if you the blog via a Steady Membership or at Patreon would support.


  1. To says:

    if I want to redirect the domain without www and with www to an external domain (with 301), what would the code look like?
    Thank you

    • sir appleot says:

      Hello Till!

      Untested, but it should work like this:

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

      Then you route both the calls to www. as well as those without www. continue on However, if these start with www. should begin, you just write in the last line instead of just

      I hope that's what you mean :)

Leave a Comment

Your e-mail address will not be published.