WordPress Redirect to New Domain .htacess Example

recently as some of you may notice i’ve redirect my main domain to a new sub domain for the blog, to do so i’ve used .htacess file with the proper SEO redirection to make sure site links and the blog stay as is. Here are the simple rules of the htacess for the redirect:

RewriteEngine On

RewriteCond %{HTTP_HOST} !^www\.blog.lior\.live$
RewriteRule (.*) https://www.blog.lior.live/$1 [R=301,L]

For important rules when doing such a reirection:

  1. Turn rewrite engine on, otherwise you won’t be able to rewrite condition or rules into htacess file.
  2. Create the htaccess file with dot!
  3. restart your apache change once you apply any changes to your htaccess files: sudo service apache2 restart

once you done the redirect, don’t forget the following:

  1. you want to use wordpress plugin that will automaticlly change all links in your posts and pages into the new url, because at some point users will not come back to your previous domain or the previous domain will expire.
  2. you want to update external links to the new URL, that including parthnership and in some cases emailing or msging relevant people to update their links.
  3. test internal links like blog posts links and pages links and see they are redirect properly.
  4. in complicated situation advice professional and expert SEO and engineers.
  5. go to search engine console by google and track the transition is doing as expected.
  6. in some cases you’ll want to notify your users in advance for upcoming chages to your site.

Good luck!

Leave a Reply

Your email address will not be published. Required fields are marked *

All rights reserved 2024 ©