rel=canonical Tag in HTTP Header

on June 17, 2011, Google announced their support for rel=”canonical” HTTP headers. This can come in handy if you see duplication of content across different file types. It basically allows webmasters to assign a file a rel=canonical tag that references an HTML document as the real (canonical) URL. This tag will be very helpful for many websites out there that currently offer the information on their HTML web pages as a downloadable PDF. For instance, a power tool company may be offering information on Air Wrench User Guide as both an HTML page and as a downloadable brochure in PDF format:

http://www.handtoolsite.com/air-wrench-user-guide.html

http://www.handtoolsite.com/air-wrench-user-guide.pdf

In this instance, with both files serving up the same content, a sever-side canonical tag could be applied.

All very well and good, but how do you apply it? If you’re using ASP.net, Classic ASP or PHP web pages, here’s how:
ASP.Net C#:
<%Response.AddHeader(@”Link”,@”< http://www.yoursite.com/>; rel=””canonical”””);%>

ASP VBScript:
<%Response.AddHeader “Link”,”< http://www.yoursite.com/>; rel=””canonical”””%>

PHP:
; rel=\”canonical\””);?>

After you modified the server HTTP header, next time when the web page is requested the server will respond with a 200 status as well as the link header telling Google that the page is a canonical of the URL specified.

About 

Li Ma is a Chicago based SEO strategist. He has extensive knowledge and experience in Search Engine Optimization and other Digital Marketing best practice and tactics.

    Find more about me on:
  • googleplus
  • twitter
  • linkedin

This entry was posted on Thursday, July 7th, 2011 at 12:37 pm and is filed under SEO, Web Design. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

One Response to “rel=canonical Tag in HTTP Header”

  1. car-repos Says:

    Hi there, i just wanted to drop you a line to say that i thoroughly enjoyed this particular post of yours, I have subscribed to your RSS feeds and have skimmed a few of your posts before but this one really stood out for me. I know that I am just a stranger to you but I figured you might appreciate the appreciation :) – Take care – and keep blogging.