In the lead-up to our SharePoint 2010 website launch I’ve been doing a fair amount of research in to the SEO Tools that work with SharePoint. We’ve been looking at automatic/scheduled generation of sitemaps, robots.txt management and conversion of 302 (temporary) to 301 (permanent) redirects. There are a couple of approaches to tackling the first two issues, which I’ll discuss in my next post, but this last issue is more peculiar to SharePoint, as you will have noticed if you’ve ever looked at Fiddler when you browse to the root of a path. For instance, if I browse to the root of my http://publishing/ publishing site I will be automatically redirected to http://publishing/Pages/default.aspx. On a blank site template I would be redirected from http://blank/ to http://blank/default.aspx. In each case SharePoint issues a 302 temporary redirect from the root of the path to the default page. This is not optimal for search on the internet, so many people have tried to rewrite the URL using the IIS URL Rewrite module. Unfortunately, “rewrites” are not supported with SharePoint but I have never seen this explained clearly. To clarify, this is what we’re talking about:
- SharePoint automatically (temporarily) redirects from the root of a path to the default page for that path.
- Using the IIS URL Rewrite tool to rewrite SharePoint URLs is not supported.
- Using the IIS URL Rewrite tool to redirect SharePoint URLs is supported. In this scenario you write regular expressions that will capture the default 302 redirections and override them with 301s.
- Using the URL Rewrite tool to redirect your way out of the default page redirection (in order to render pages at the root) will not work.
I’ve seen these second and third points discussed before, but I decided to delve in to the final scenario, because I didn’t understand why this wouldn’t work at a glance, nobody seemed to be talking about it and it didn’t seem to be unsupported. In this case I inverted Jie Li’s approach from the third scenario. I configured the Rewrite module to permanently redirect (301) from */Pages/default.aspx to the root of the path.
I cracked open Fiddler and browsed to the root of my test site, http://published/. The page never loaded and Fiddler clearly explains why:
I’d effectively created an endless loop. SharePoint temporarily redirects to the default page and the default page is permanently redirected back to the root by IIS (which is thankfully smart enough to kill the loop after a few attempts). So this will never work. This is one aspect of SEO where we will struggle to optimise SharePoint by removing the extra depth of the path and the file name, but there are enough other options available to optimise ranking that we won’t be losing any sleep over this behaviour.