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.

Follow this link for a SharePoint 2010 version of the same project: http://sp2010list404handler.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 12 hive, and you'll also see 3 Features that need to be Activated:
  1. A Site (web) scoped feature that adds a List Template for the URL Redirect list
  2. A Web Application scoped feature that configures the Web app's file not found property, and adds a URL Redirect List to the Root Web of the Farm's first Site Collection
  3. A Farm scoped feature that adds a link to the Operations page of Central Admin, enabling you to change each Web Application's file not found property manually

By Activating the first two Features, you will be able to use the List (usually called URL Redirect) 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

The source code was written in Visual Studio 2008 Professional v9.0.30729.1 and requires WSP Builder v0.9.9.0728 for building the WSP.

The WSP has been tested with MOSS 2007 v12.0.0.6421.

Thanks goes to Rafael Perez, and his blog posting here which was used as a starting point for the base Custom 404 ASPX code, and the settings page for Central Admin.

Last edited Mar 7, 2011 at 11:24 AM by mpowney, version 9