Recently we have had several cases where we have started to work on a website and found out that there is more than one domain with the same content on the site. Normally this is a completely innocent case; the owner of the website may have multiple domains for the same company or product. For example they may have the .co.uk and the .com version of the domain. Unfortunately it is quite frequent that the client has set up a domain alias for the domains, where the alias essentially duplicates the original.

The problem with this is that it is believed that search engines like Google will perceive the alias as duplicate content and possibly can black mark both sites, penalising you for duplicate content.

If you have multiple versions of your domain or you decide to move over to a new domain it is important that you should implement a 301 redirect for the entire site or for any pages on your site that need redirecting.

A 301 Redirect is a method of telling web browsers and search engines that a web page or site has been permanently moved to a new location. Usually a 301 redirect includes the address to which the resource has been moved. Web browsers will typically follow 301 redirects to the new location automatically, without the need for user action.

A 301 redirect should be used whenever a website is moved to a new domain name (URL) so that search engines will quickly change their indices and, in theory, preserve the search engine rankings that the site had at the previous domain.

How do you implement a 301 redirect?

This depends on what you host your site on, or what language you have used on your site but here are the most common solutions.

 IIS Redirect

* In internet services manager, right click on the file or folder you wish to redirect
* 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’

ASP Redirect
<%@ Language=VBScript %>
<%
Response.Status=”301 Moved Permanently”;
Response.AddHeader(“Location”,”https://www.new-url.com/”);
%>

ASP .NET Redirect
<script runat=”server”>
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = “301 Moved Permanently”;
Response.AddHeader(“Location”,”https://www.new-url.com”);
}
</script>

PHP Redirect
<?
Header( “HTTP/1.1 301 Moved Permanently” );
Header( “Location: https://www.new-url.com” );
?>

JSP (Java) Redirect
<%
response.setStatus(301);
response.setHeader( “Location”, “https://www.new-url.com/” );
response.setHeader( “Connection”, “close” );
%>

CGI PERL Redirect
$q = new CGI;
print $q->redirect(“https://www.new-url.com/”);

Ruby on Rails Redirect
def old_action
headers[“Status”] = “301 Moved Permanently”
redirect_to “https://www.new-url.com/”
end

Redirect Old domain to New domain (htaccess redirect)

Create a .htaccess file with the below 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 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 (.*) https://www.newdomain.com/$1 [R=301,L]

Please REPLACE www.newdomain.com in the above code with your actual domain name.

In addition to the redirect I would suggest that you contact every backlinking site to modify their backlink to point to your new website.

Note* This .htaccess method of redirection works ONLY on Linux servers having the Apache Mod-Rewrite moduled enabled.

Redirect to www (htaccess redirect)

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 ^(.*)$ https://www.domain.com/$1 [r=301,nc]

Please REPLACE domain.com and www.newdomain.com with your actual domain name.

Note* This .htaccess method of redirection works ONLY on Linux servers having the Apache Mod-Rewrite moduled enabled.

How to Redirect HTML

Please refer to section titled ‘How to Redirect with htaccess’, if your site is hosted on a Linux Server and ‘IIS Redirect’, if your site is hosted on a Windows Server.