Contact us

March 14, 2006

Canonical domain 301 redirects

Filed under: seoKevin Gibbons @ 12:03 am

During the re-design of this website I have ensured that a canonical form of domain listing is not indexed by redirecting kevingibbons.co.uk to www.kevingibbons.co.uk. This is important as a website can be penalised if it has duplicate content appearing in the SERPs. The best way of redirecting the canonical url is via a 301 redirect which lets the search engines know that the page has been permanently moved. This is generally setup via server settings such as .htaccess or an IIS redirect but as my hosting account does not allow this I have had to hardcode this into the site. I’ve added the code to redirect to the www subdomain below using .htaccess and both ASP and PHP.

ASP Subdomain Redirect Code:
<%
If Request.ServerVariables(”HTTP_HOST”) = “mysite.com” Then
Response.Status=”301 Moved Permanently”
Response.AddHeader “Location”, “http://www.mysite.com” & Request.ServerVariables(”PATH_INFO”)
End If
%>

PHP 301 Subdomain Redirect Code:
<?
if ( strtolower($_SERVER['HTTP_HOST']) == “mysite.com” )
{
header(”HTTP/1.1 301 Moved Permanently”);
header(”Location: http://www.mysite.com” . $_SERVER["REQUEST_URI"]);
exit();
}
?>

.htaccess Apache mod_rewrite 301 redirection:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mysite\.com [nc]
RewriteRule (.*) http://www.mysite.com/$1 [R=301,L]

If you need to redirect an individual URL using .htaccess you should use the following line of code:
Redirect 301 /filename http://www.domain.com

Microsoft IIS 6.0 301 redirects
Via Microsoft Support:

To redirect browser requests to another folder or Web site:
1. Start Internet Services Manager.

Alternatively, start the IIS Snap-in in Microsoft Management Console (MMC).
2. Click to expand * server name, where server name is the name of the server.
3. Right-click either the Web site or the folder that you want to redirect, and then click Properties.
4. Click one of the following tabs that is appropriate to your situation:
• Home Directory
• Virtual Directory
• Directory
5. Under When connecting to this resource, the content should come from, click A redirection to a URL.
6. Type the URL of the destination folder or Web site in the Redirect to box.

For example, to redirect all requests for files in the Products folder to the NewProducts folder, type /NewProducts. To redirect all requests for files located at www.mycompany.com/products to sales.mycompany.com/newproducts, type http://sales.mycompany.com/newproducts.
7. Click OK.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • bodytext
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Propeller
  • NewsVine
  • Reddit
  • StumbleUpon
  • Technorati
  • TwitThis

2 Comments »

  1. [...] recommend, but I felt it would be best to offer the SEO blog as part of the new website. Using a 301 redirect from the old domain to let the search engines know the page has been permanently [...]

    Pingback by Changing domain name | SEOptimise — February 15, 2008 @ 11:39 pm

  2. [...] redirects mod_rewrite, 301/401 Redirects & Optimizing Apache Canocial domain 301 redirects 5 htaccess Tricks Every Webmaster Should Know Apache Redirect [...]

    Pingback by 78 Essential Search Engine Marketing & SEO Resources! | SEOptimise — July 8, 2008 @ 10:29 am

Leave a comment

Subscribe

RSS Feed


What is RSS?

Subscribe by email:

Top 10 Popular Articles

10 Ways To Make Your Website More Popular
5 Web Design Elements to Earn Your Visitors Trust
78 Essential Search Engine Marketing & SEO Resources
Which Domain Internationalisation Strategy to Use?
Why Google Universal Search Should be Part of Your SEO
Top 10 Fatal Localisation Mistakes
How To Increase StumbleUpon Traffic?
Ultimate Social Media Optimisation List
User Generated Content Can Ruin Your SEO
6 Reasons Why Link Building Is So Hard

Latest SEO Blog Posts

Google Sending Invites to Google Friend Connect - Join SEOptimise!
30 Tips on How to Get, Convince, Keep and Deal With Clients, Be it in Web Design, Writing or SEO
Using Google Analytics Advanced Segmentation to Get Proper Ad Scheduling Data
12 Indispensable Readability Measures to Increase Conversions
6 Resources for Finding Negative Keywords
30+ Very Useful Twitter Tools You Must Be Aware Of
Google SEO Starter Guide is Great News for Small Businesses
Google Analytics Tip - How to Find All AdWords Search Queries Triggered from Phrase/Broad Matches
Keyword Research: 7 Keyword Modifiers to Optimise New Websites For
The Lazy Bloggers Guide to Quality Content & Social Media Success
"If we knew what it was we were doing, it would not be called research, would it?"Albert Einstein (1879 - 1955)