301 redirect is a method to redirect a webpage, it is very popular method for webpage redirection as it is most efficient and Search Engine Friendly. Following are some methods for implementing 301 redirection.
Redirect Old domain to New domain through htaccess redirect
First of all create a .htaccess file with the below given code, it will ensure that all your directories and pages of your old domain will get correctly redirected to your new domain.
The .htaccess file has to be placed in the root directory of your old website (i.e the same directory where your index file is placed)
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]
Replace www.newdomain.com in the above code with your actual domain name.
Limitation — This .htaccess method of redirection works ONLY on Linux servers having the Apache Mod-Rewrite moduled enabled.
Redirect to www by htaccess redirect
First of all create a .htaccess file with the below code, it will ensure that all requests coming in to domain.com will get redirected to www.domain.com
The .htaccess file needs to be placed in the root directory of your old website (i.e the same directory where your index file is placed)
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]
Replace domain.com and www.newdomain.com with your actual domain name.
Limitation — This .htaccess method of redirection works ONLY on Linux servers having the Apache Mod-Rewrite moduled enabled.
WordPress Redirect
add this meta tag in your header.php for doing the redirection.
<meta http-equiv=”REFRESH” content=”0;url=http://the-new-domain-to-redirect-to.com”>
CGI PERL Redirect
$q = new CGI;
print $q->redirect(”http://www.new-domain.com/“);
Ruby on Rails Redirect
def old_action
headers["Status"] = “301 Moved Permanently”
redirect_to “http://www.new-domain.com/”
end
IIS Redirect
- In internet services manager, right click on the file or folder you wish to redirect
- Then select the radio titled “a redirection to a URL”.
- Enter the redirection page
- Check “The exact url entered above” and the “A permanent redirection for this resource”
- Click on ‘Apply’
ColdFusion Redirect
<.cfheader statuscode=”301″ statustext=”Moved permanently”>
<.cfheader name=”Location” value=”http://www.new-domain.com“>
ASP Redirect
<%@ Language=VBScript %>
<%
Response.Status=”301 Moved Permanently”;
Response.AddHeader(”Location”,”http://www.new-domain.com/“);
%>
ASP .NET Redirect
<script runat=”server”>
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = “301 Moved Permanently”;
Response.AddHeader(”Location”,”http://www.new-domain.com“);
}
</script>
JSP Redirect
<%
response.setStatus(301);
response.setHeader( “Location”, “http://www.new-domain.com/” );
response.setHeader( “Connection”, “close” );
%>


There is also a WP plugin for 301 redirect.
Or you can use this method to do such redirections.
Open the file .htAccess file present in /public_html/yourDomain folder using an ftp client.
Add an entry in it Redirect 301 /oldPath http://www.subdomain.yourdomain.com/
for moving the entire site you can use this Redirect 301 / http://www.example.com/
Save the file and upload it to your server in in ASCII mode.
Before Code change:
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
After Code Change :
# BEGIN WordPress
RewriteEngine On
RewriteBase /
301 /oldPath http://www.subdomain.yourdomain.com/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
Yeah Nirmal you are right,, there is a plugin, called “Permalink Redirect WordPress Plugin” It can be downloaded from http://fucoder.com/code/permalink-redirect/
This is definitely a good guide. Thanks for this.