A simple method to redirect all pages to new domain (with .htaccess)

Redirect All Pages From One Domain To Another

Migrating from one site to another might seem easy, but it is involved in a lot of complexities as well. One of the main concerns is to redirect all pages to new domain

While you are migrating, it is important that you don’t break any of the links that would be existing on your old domain. 

A proper redirection of all the pages from your old domain to the new domain ensures that the visitors of the old domain end up in the right place.

And in case it fails to redirect, you might face a loss of visitors as well as search engine rankings that you would have worked so hard for.

Usually, when you change your domain, you keep the pages in the same way on the new domain. Rather than redirecting all the pages of the old domain to the homepage of the new domain, you want all of those on the correct internal pages.

 

So, in order to help you out, I have made this rather small and easy tutorial to redirect all the pages from your old domain to a new one with .htaccess.

 

Redirect all pages to another domain with .htaccess:

You would want to start with setting the nameservers and going into cPanel followed by adding the domain. Now, you add the .htaccess file which 301 redirects all the internal pages to your new domain. 

Now for the .htaccess code, here it is –

<IfModule mod_rewrite.c>

  RewriteEngine On

  RewriteCond %{HTTP_HOST} ^yourolddomain.com$ 

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

</IfModule>

 

In case you have made any kind of changes to the structure of your site, you would see the lines above the old domain. Though you would also need to make redirects in your .htaccess file on the new domain for handling all kinds of changes the site undergoes.

For the sake of redirecting a single page towards a new location of the same domain, you have to use the following syntax:

 

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

 

There’s another method for us to try – Domain forwarding.

 

DOMAIN FORWARDING

This method usually is simple and doesn’t require a lot of effort. I would still mention the steps. 

We would start by going into the DNS manager. One of my domains is bought from GoDaddy, which means I would stick to that tutorial only. 

redirect all pages to new domain

However, this method is common for all the domain registrars, and this means you can figure out the working solution easily. 



For domain forwarding, you put the destination of the domain in the ‘Forward to’ box and select ‘http:// or https://’.

Click on ‘Update my nameservers and DNS settings’ and keep everything the way it is.

Click on ‘Save’ and wait for a few hours for the DNS to get updated.

redirect all pages to new domain

This is a common method and if it works, no need to do anything else. 

 

CONCLUSION

The whole process to redirect all pages to new domain is usually simple, yet you need to take care of every step or you might mess up your domain settings.

If you have are stuck at any step, drop a query in the comments and I will try to answer you.

Share on facebook
Facebook
Share on google
Google+
Share on twitter
Twitter
Share on linkedin
LinkedIn
Share on pinterest
Pinterest
Share on facebook
Share on google
Share on twitter
Share on linkedin
Share on pinterest

Leave a Comment

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

Scroll to Top