How to redirect all urls to a new domain with .htaccess

  • How to drive your old domain's traffic to the new one using .htaccess

  • What to do after you changed your domain name in order to not loose your previous traffic

How to redirect all urls to a new domain with .htaccess

Supose that you changed the name of your domain and you want to take all your traffic to a new domain. Redirecting all your old urls to a new domain will not only help your users to know about it but also seach engine will know about it and start crawling it.

By adding the following 3 lines to the .htacces file in the root folder of your old domain will do the entire work for you:

 

RewriteEngine on

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

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

RewriteRule ^(.*)$ "https://newdomain.com/$1" [R=301,L]

 

 

Posted On: Nov 24,2022