Views:

A 301 redirect is the best search engine and user-friendly method for webpage redirection. Redirects take a visitor from one URL to the next URL.

Although redirects may serve many purposes, the main SEO purpose is to serve one copy of each page to the search engines. The 301 code is interpreted as moved permanently. Having multiple URLs that all go to the same website may be viewed by Google® and other search engines as different websites, which could create duplicate content penalties. By making one URL dominate over the other helps reduce the possibility of a duplicate content penalty.

For technical reasons, you should only implement a redirect when no Content Management System, or CMS, is available and when your website is running on a Unix®/Apache® server. When you attempt to modify the necessary file when a CMS is present, there is a risk that your entire website will break. As our Customer Service and Technical Support teams do not provide support for creating this type of custom code, we are providing this information for your reference.

The following sections represent a few methods of URL Redirection:

ColdFusion Redirect

<.cfheader statuscode="301" statustext="Moved permanently">
<.cfheader name="Location" value="http://www.newdomain.com">

PHP Redirect

<?
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.newdomain.com" );
?>

ASP Redirect

<%@ Language=VBScript %>
<%
Response.Status="301 Moved Permanently"
Response.AddHeader "Location","http://www.newdomain.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.newdomain.com");
}
</script>

JSP (Java) Redirect

<%
response.setStatus(301);
response.setHeader( "Location", "http://www.newdomain.com/" );
response.setHeader( "Connection", "close" );
%>

CGI PERL Redirect

$q = new CGI;
print $q->redirect("http://www.newdomain.com");

Redirect Old Domain to New Domain (htaccess redirect)

Create a .htaccess file with the following code, which ensures that all your directories and pages of your old domain will get correctly redirected to your new domain.

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
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]

Note: Replace www.newdomain.com in the above code with your actual domain name.

We recommend that you also contact every backlinking site to modify their backlink to point to your new website.

Note: The .htaccess method of redirection only works on Linux servers that have the Apache Mod_Rewrite module enabled.

Redirect to WWW (htaccess redirect)

Create a .htaccess file with the following code, which ensures 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]

Note: Replace www.newdomain.com in the above code with your actual domain name.

Note: The .htaccess method of redirection only works on Linux servers that have the Apache Mod_Rewrite module enabled.

How to Redirect HTML

Please refer to section above titled Redirect to WWW if your site is hosted on a Unix Server.