Posted by Arjun Arjun on Friday 17th October 2014, 1 minute read

Redirect all pages to new domain with Htaccess

How to

if you want to change your domain name without affecting SEO Ranking in search engines than you should think about 301-page redirect, with 301 redirect you can move your web application to new domain freely.

we can use different methods for setting 301 redirects from old domain to new domain but I am gonna use .htaccess. this method is most preferred, effective and easy.

create the .htaccess file in your old website root folder then put below lines in the .htaccess file.

RewriteEngine on 
RewriteRule ^(.*)$$1 [R=30

Here, this one redirects everything after the domain name on the URL to the exact same copy on the new domain URL., for example, will redirect to

if you remove $1 , all pages redirect to home page Ex: this will effect search engine rankings.


I am Arjun from Hyderabad (India). I have been working as a software engineer from the last 7+ years, and it is my passion to learn new things and implement them as a practice. Aside from work, I like gardening and spending time with pets.