August 31st, 2012

An improved 301 Redirect Module for Sitecore

This post is about a recent contribution Igloo has made to Sitecore Shared Source: an enhancement to the 301 Redirect Module, which was contributed to Shared Source by Chris Castle in late 2011.

If you maintain a website you have almost certainly needed to move pages around. Maybe your site got restructured, some section of your site was renamed, or a shorter URL is required for an ad campaign. You need to make sure existing links to your site continue to work, or you’ll lose out in search engine rankings and frustrate users who’ve bookmarked your site. The main tool available to website administrators is the redirect, but Sitecore doesn’t manage redirects out of the box.

Sitecore users have a few options to keep links working.

  • Redirection before the request reaches Sitecore, such as with IIS URL Rewrite
  • Clone items, which avoid redirecting but clutter the site tree.
  • A home-grown solution: usually a Sitecore Pipeline to intercept requests and redirect if they match certain rules.
  • The Sitecore Shared Source 301 Redirect Module. This uses items to specify what redirects are in place, so content editors can add, edit and remove redirect rules without developers getting involved – the holy grail of content management.

At Igloo we were using a home-grown solution as described, but were running into challenges. We looked at the Shared Source 301 Redirect Module to see if it could help.

The redirect module already had a couple of great, unique features:

  • Redirects are items. They can be put through workflows, published, unpublished.. – but most importantly, they can be seen and altered by content editors – the holy grail of content management.
  • Regular expression support in the redirect module gives a lot of flexibility – for instance, you can redirect all URLs under an area of your site to another place.
  • Although the redirect module runs on every request to your site, if the URL is valid (ie. it matches an item in Sitecore), the redirect module does nothing. This keeps your site nice and fast.
  • It is URL based rather than template based, so any item can be fetched without needing to know its template in advance.

Our requirements were:

  • Let content editors manage redirects.
  • Don’t clutter the site’s item tree with items whose only purpose is redirecting.
  • Ability to redirect part of a query string, so we could, for example, configure requests to /basketball?colour=pink to redirect to /basketball?colour=orange.
  • Redirect for some URLs some of the time, even if the URL is correct.
  • Minimum impact on overall performance of the site.

So we enhanced the redirect module to meet our requirements. Now we’re contributing our work back to Shared Source for the benefit of the community! Here’s what we’ve added:

  1. The ability to work with Sitecore friendly URLs:
    If a user requests and you configure a redirect to, the module correctly maps the redirected request to a Sitecore item called “My Renamed Page”. (In other words, the enhancement supports Sitecore’s ability to map spaces in Sitecore items’ names to hyphens in URLs and vice versa, and deal with URL-encoded spaces. The original module doesn’t do this.)
  2. Case insensitivity when matching URLs. A request to will be treated the same as a request to
  3. The redirect module normally only works on URLs which don’t exist in Sitecore; this is for performance reasons. With this enhancement you can specify a (small) set of items be specified for which redirects will still be processed:
  1. Ability to use regular expressions to control what portion of the query string, if any, is included when the redirect is issued. You can use this to add, change or remove parts of the query string when redirecting. Combined with the above feature this makes the redirect module very powerful and flexible. Here’s an example (more examples are available below if you click on the GitHub link):

More information can be found in the README at this GitHub repository, or at the Sitecore Developer Network Forum post.

Posted by admin


For the benefit of those coming across this post in the future, the author of the updated module (Chris Adams) has stated that the sitecore marketplace module is not the updated version found on github (as at 15 Jan 2013).

Comment by Joshua McKinney January 16, 2013 @ 10:51 am

Hello, We are updating our web site and will need to enter hundreds of 301 redirects from the old pages that will no longer exists to the new replacement pages. Is there a way to to a bulk import?

Comment by Joey Uhl February 27, 2013 @ 12:03 am

Does this Sitecore module support language versions and language fallback? Are you able to create a different 301s for different language versions?

Comment by Mike Green April 01, 2013 @ 5:36 pm

Leave a Comment

OK. Let’s get down to it. So what do you think of that? Agree? Disagree? Don’t really care? Got something to say. Then say it.

(won’t be published)