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: //altedoamin.de [NC] RewriteRule ^ (. *) $ Http://neuedomain.de/$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: //altedoamin.de [NC] RewriteRule ^ (. *) $ Https://neuedomain.de/$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.

-
 

 

Effectively for free: iPhone 13 Mini and iPhone 13 deals with top conditions at Otelo - Advertisement

2 comments

  1. To says:

    Hallo,
    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 Apfelot says:

      Hello Till!

      Untested, but it should work like this:

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

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

      I hope that's what you mean :)

Leave a Comment

Your e-mail address will not be published. Required fields are marked with * .