How to redirect all traffic to the new website using .htaccess?

It’s very rare that anyone changes the main domain of the website, but it’s still possible. The main issue which you may face while shifting to a new domain is how to redirect all traffic, that is old URLs to their appropriate new URLs.

For example, should NOT redirect to just

Ideally, it should redirect to

You may ask why it’s necessary to redirect exactly to the same page? Well, good question. It’s important from an SEO viewpoint. If your old domain is very old, chances are that you must be having some good SEO score, and you don’t want that to go to drain. Using exact redirection, we can borrow the old site SEO score to the new site. This is also important to maintain the search listing location on Google and similar search engine websites.

Now, let’s get to the good stuff, how to redirect?

Requirements: Knowledge of creating a file on the server, hosting for the old domain.

If you are using cPanel, you can easily follow the below tutorial. If you are using other control panels or FTP, the process is very similar.


Login to cPanel, go to File Manager and navigate to your root directory of the domain. (Usually, it is something like public_html or public)

Create a new file .htaccess

Edit that newly created file and paste the following content.

RewriteEngine on 
RewriteRule ^(.*)$ http://NEWDOMAIN.COM/$1 [R=301,L]

Make sure you change NEWDOMAIN.COM with your own domain name.

In case if you are not able to see .htaccess file, click on “Settings” button (top right corner) and enable checkbox “Show Hidden Files”

That’s it! Now, check if all the links are redirecting properly or not. You can do the same process for any subdomains you have on your website.

Using .htaccess is one of the simplest ways to redirect traffic. However, you can also utilize other methods like DNS, Domain provider’s redirection, etc.

If you want to know more about what is htaccess all about, you can read this fantastic article on WPBeginner – What is htaccess in WordPress?

Scroll to Top