Saturday, October 16, 2010

Sorting out Canonical Issues for SEO

Information on how to use Canonical link reference, and 301 redirects (permanent redirect) to fix duplicate issues in SEO

I am still surprised at the number of websites I come across daily with this problem. The following information is supplied to look at resolving this issue.

--------------------------------

Set the Canonical source reference, indicating the primary page where ranking is to be delivered if you have duplicate content, by including the following metatag. The following tag tells the SEs to treat the page that they are on as if it is a copy of the listed domain/page, and that all of the link and content metrics that the engines apply should technically flow back to that URL.

<link rel='canonical' href='http://www.domainname.com.au' />


Note: 301s carry cross-domain functionality, meaning you can redirect a page at domain1.com to domain2.com and carry over those search engine metrics. This is NOT THE CASE with the Canonical URL tag, which operates exclusively on a single root domain (it will carry over across subfolders and subdomains).

The “301 Permanent Redirect” is the most efficient and search engine friendly method for redirecting websites. You can use it in several situations, including:

    * to redirect an old website to a new address
    * to setup several domains pointing to one website
    * to enforce only one version of your website (www. or no-www)
    * to harmonize a URL structure change

--------------------------------

ASP Sites – 301 Redirect

<%@ Language=VBScript %>
<%
Response.Status=”301 Moved Permanently”
Response.AddHeader “Location”, “http://www.example.com/keyword.asp”
%>

--------------------------------

ASP Single Page 301 Redirect (a variation on the above)

This redirect method is used with the Active Server Pages platform.

<%
Response.Status="301 Moved Permanently"
Response.AddHeader='Location','http://www.new-url.com/'
%>

--------------------------------

ASP Canonical Redirect

The Canonical Redirect with ASP must be located in a script that is executed in every page on the server before the page content starts.

<%
If InStr(Request.ServerVariables("SERVER_NAME"),"www") = 0 Then
Response.Status="301 Moved Permanently"
Response.AddHeader "Location","http://www."
& Request.ServerVariables("HTTP_HOST")
& Request.ServerVariables("SCRIPT_NAME")
End if
%>

--------------------------------

PHP Single Page 301 Redirect

In order to redirect a static page to a new address simply enter the code below inside the index.php file.

<?
Header(“HTTP/1.1 301 Moved Permanently”);
Header(“Location: http://www.new-url.com/page.html”);
exit();
?>

--------------------------------

PHP Canonical Redirect

The Canonical 301 Redirect will add (or remove) the www. prefixes to all the pages inside your domain. The code below redirects the visitors of the http://domain.com version to http://www.domain.com.

<?php
if (substr($_SERVER['HTTP_HOST'],0,3) != 'www') {
header('HTTP/1.1 301 Moved Permanently');
header('Location: http://www.'.$_SERVER['HTTP_HOST']
.$_SERVER['REQUEST_URI']);
}
?>

--------------------------------

PHP Sites – 301 Redirect: Add to .htaccess file

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.com
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
RewriteRule ^index.html$ / [R=301,L]

--------------------------------

Apache .htaccess Singe Page Redirect for Linux Servers

In order to use this method you will need to create a file named .htaccess (not supported by Windows-based hosting) and place it on the root directory of your website, then just add the code below to the file.

Redirect 301 /old/oldpage.htm /new/http://www.domain.com/newpage.htm

--------------------------------

Apache .htaccess Canonical Redirect for Linux Servers

Follow the same steps as before but insert the code below instead (it will redirect all the visitors accessing http://domain.com to http://www.domain.com)

Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]

--------------------------------

1 comment:

  1. Thanks for the informative post on canonical issues and error messages.

    SEO Sydney

    ReplyDelete