As we have discussed the various type of redirection earlier, this time we will learn the most important aspect of redirection for SEO point of view – 301 redirection which means the file or folder has been moved to somewhere else permanently.
So, Let’s get going.

Scene 1. We have changed a file name on our existing website from file name “x.html” to the new file name “y.html” due to any reason.
What we do:

redirect 301 /x.html

Scene 2. We have changed the file name extension from “x.html” to file name “y.php” or “y.xml” (We have use y.php in below code.) for this we write :

redirect 301 /x.html

Scene 3.  We want to move our site from “one existing domain”  to “some other new Domain”.  For example to,

We will write :

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^$ [NC]
RewriteRule ^(.*)$$1 [L,R=301]