How To Implement rel=”canonical” HTTP Headers

by Alex Harvey July 6th, 2011 

Google recently announced their support for rel=canonical HTTP headers. This can come in handy if you see duplication of content across different file types.

It allows webmasters to assign a file a tag that references an HTML document as the real (canonical) URL. This tag will come in hand for any website that currently offers the information on their HTML web pages as a downloadable PDF. For instance, a holiday company may be offering information on Australian holidays as both an HTML page and as a downloadable brochure in PDF format:

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 youre using, Classic ASP or PHP web pages, heres how:

ASP.Net C#:

<%Response.AddHeader(@Link,@<>; rel="canonical");%>

ASP VBScript:

<%Response.AddHeader Link,<>; rel="canonical"%>


<?php header(Link: <>; rel=canonical");?>

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.

Alex Harvey

Alex works for Fresh Egg, an SEO and multi discipline search agency. He has an extensive background as a web developer.

SEO & Web Design Blog

You May Also Like

One Response to “How To Implement rel=”canonical” HTTP Headers”

  1. Joydeep says:

    Hi Alex,

    Really helpful post, but can you tell me how do I implement rel="canonical" using .HTACCESS file?


More in Web Design
10 Easy Ways to Combine Usability & SEO to Increase Conversions

Combine these SEO and usability tips to boost the human interaction performance of your site.