How to add 301 permanent redirect using .htaccess?

Most of times we stuck in getting out of situations where it demands some kind of redirects whether its permanent redirect or a kind of temporary redirect (302).

Permanent Redirect:

If you need to change the URL of a page as it is shown in search engine results, we recommend that you use a server-side 301 redirect. This is the best way to ensure that users and search engines are directed to the correct page. The 301 status code means that a page has permanently moved to a new location.


To add a 301 redirect or a permanent redirect You can write the below code in Your website’s .htaccess file:

Redirect 301 /oldpage.php /newpage.php 


Redirect 301 /oldpage.php    

Now lets have a scenario where you want to add one or many 301 redirects

e.g.1: to
e.g.2: to

Here in this case domain is a new domain not parked anywhere or is without any associated hosting account and a complete website is running at domain

So in order to add 301 cross domain redirect from to

Please follow the steps as mentioned below:

Add your new domain to any hosting account and point it to a blank folder (lets say blank folder name is  xyz). 
Now update the domain A record to point to the hosting account
Create a file with the name .htaccess inside the folder xyz
Add the below lines in your .htaccess file

Redirect 301 /abc to

Now, to add multiple redirects, just copy the above lines and replace it with appropriate web page urls.
Good Luck 🙂

Related Post