Migrating your site to a new domain is a very risky task. While doing this task, you can break all the pages and links of your website. You can even lose your google ranking.

Fortunately, this task becomes easy when you’re running on an apache website. This is because apache allows you to migrate your site to a new domain using .htsaccess.

How to Redirect from old domain to new domain using Htaccess

It is pretty easy to redirect your website from an old domain to a newer one using .htaccess. If you have not made any major changes in the structure of your website, just add the following lines in the .htaccess file which is located at the root of your old domain.

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteCond %{HTTP_HOST} ^olddomain.com$ [OR]

RewriteCond %{HTTP_HOST} ^www.olddomain.com$

RewriteRule (.*)$ http://www.newdomain.com/$1 [R=301,L]


In case you have made some changes to the structure of your website then you will have to create redirects in the .htaccess file on your new domain.

You can use the following syntax in order to redirect a single page to a new location.

Redirect 301 /old/old.htm http://www.domain.com/new.htm

After creating the redirects in the .htaccess file, add the lines that we mentioned above to the .htaccess file on your old domain.

Summing Up:

This was a very simple tutorial of migrating your website from an old domain to a newer one using .htaccess. This is a very safe method and you are not risking any important data on your site by following the steps that we mentioned.

If you have any sort of queries regarding this tutorial or migration of domains in general then make sure to leave them in the comments below.

Previous ArticleNext Article

Leave a Reply

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