advertisement
Several weeks ago Google announced support for link rel="canonical" relationships specified in HTTP headers as per the syntax described in section 5 of IETF RFC 5988.
Editors Note: As a quick aside, Website Magazine will feature a very practical article from Prashant Puri on canonicalization in the Small Business Lab column of our September issue.
Webmasters can use rel="canonical" HTTP headers to signal the canonical URL for both HTML documents and other types of content such as PDF files. For example, perhaps you have a white paper as an HTML page and as a PDF using two URLs - example.com/white-paper.html and example.com/white-paper.pdf. SEO's can signal to Google that the canonical URL for the PDF download is the HTML document by using a rel="canonical" HTTP header when the PDF file is requested.
So 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 BLOCKED SCRIPT
<%Response.AddHeader “Link”,”< http://www.yoursite.com/>; rel=”"canonical”"”%>
PHP:
<?php header(“Link: <http://www.yoursite.com/>; 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.
Google provided another instance when this might come in handy. For example, serving the same file from multiple URLs (common if using a content distribution/delivery network). The rel=canonical HTTP header could be used to signal to Google the preferred URL.