Project Description
A SharePoint WSP that customises the 404 handler for a web application, allowing you to define how to handle missing page requests via a SharePoint list. This is the SharePoint 2010 version.

Follow this link for a SharePoint 2007 version of the same project: http://splist404handler.codeplex.com/

This project is a WSP that can be deployed to your SharePoint environment via stsadm. Once deployed, you will get a bunch of static files added to various directories in the 14 hive, and you'll also see 2 Features - one of which needs to be Activated:
  1. A Site (web) scoped feature that adds a List Definition and List Instance for the URL Redirect Matches list (this feature activates itself automatically)
  2. A Web Application scoped feature that configures the Web app's file not found property, finds the URL Redirect Matches list in the site collection's Root Web, and associates itself via the list's GUID so the 404 handler ASPX file can find it

By Activating the second Feature, you will be able to use the URL Redirect Matches List to add entries to catch specific web addresses, and deal with them in one of two ways:
  1. Display a customised message on a generic 404 page - the field to enter this is a multi-line HTML field, so the message can be as long or as short as you like
  2. Redirect the user to a pre-defined web address


The entries you add to the URL Redirect list can include wildcard and Regular Expression based matching.
  • With wildcard matching, you can match all pages based on any number of wildcard (asterisk) characters in the defined URL. This might be useful when an entire site is to be removed and a special message needs to be displayed.
  • Regular Expression matching can allow all the functionality of .Net Regular Expressions to match a URL, and can use Substitutions in the Redirect URL to use a portion of the original URL in the redirect - this might be useful if you move a section of your SharePoint site from one parent location to another, but you want to maintain the directory / filename component of the request within the moved site itself.
  • Note: When regular expression matching is enabled for an entry in the URL Redirect list, the URL field needs to contain a valid Reg Ex.


A Sorting column exists in the Redirect List so you can prioritise one URL match over another - this might be useful if you have similar URLs to pick up on, or if you want to add a "catch-all" URL to the end of your URL Redirect list (simply add the catch-all with a really high Sorting numeric value).

This WSP has been developed to assist with a project in which an existing Intranet is having it's Information Architecture redefined.

Some enhancements I have in mind include:
  • With Regular Expression based matching, allow the Display Message to include Substitions from the defined Regular Expression
  • Update the List Instance to make the Title field actually have a display name of URL

The source code was written in Visual Studio 2010 Professional v10.0.30319.1 RTMRel, and uses standard SharePoint 2010 template to package the WSP

The WSP has had minimal testing on a SharePoint 2010 instance with Enterprise features enabled (although, shouldn't require the Enterprise features).

Last edited Mar 7, 2011 at 11:07 AM by mpowney, version 6