Canonicalisation – IIS

I was following links from SEOmoz twitter account and noticed someone who was asking about canonicalisation in IIS – I am exclusively experienced with IIS and my knowledge of Unix is literally zero, but it got me thinking, I had developed a selection of scripts that were pretty much an SEO toolkit, course I should have productised this and made it more consistent, rather than just cutting and pasting it into every website.

Unfortunately, I haven’t really updated my skills since ASP but I am sure the scripts can be re-written, I use a common include on all pages, something that I can put a handful of scripts and variables in (including things like the analytics code variables), so …

Canonicalisation of ‘www’ and non ‘www’

<%
var liveserver = “www.liveserver.com
if Request.ServerVariables(“server_name”) <> liveserver then 
  redirect_to = “http://” &_ 
  liveserver &_ 
  Request.ServerVariables(“url”) &_ 
  Request.ServerVariables “QUERY_STRING”


Response.Status=”301 Moved Permanently” 
Response.AddHeader “Location”, redirect_to

%>   

Of course this is written by a non-programmer, so its probably worth testing it, and I have just re-written it from memory – comments suggestions are more than welcome – this is of course is only really applicable to ensuring a single domain is returning the pages, this is something that is important in SEO, as Google will divide the links to multiple domains, which ideally you would like to consolidate, it should also improve indexation.

Find more on www.UsableContent.co.uk

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *