Constructing a 404 Handler for IIS

Previous Topic Previous Next Topic Next
Xoc Software

Other Xoc managed sites:

This is a description of how to construct a 404 handler for IIS 5.0. The 404 handler causes pages that are not found to be forwarded to another URL on the web using an error 301 Moved Permanently. The 404 handler can also be directed not to redirect a page from a given IP address, but instead return a normal 404 error. This can be used to help a web spider forget about an old location for the web page.

The basic scheme is that when a request for a page that isn't there occurs, IIS redirects to a 404 page to display. The 404 page, though does a lookup into an XML file. If it meets the correct requirements it sends a 301 redirect to the User Agent, telling it what page it should be on.


  • You will need control over the web server. If you are not your own ISP, you will need to get friendly with them to install software and configure the IIS dialogs.
  • Because it uses XML to configure the data for the 404 handler, you will need to download and install the Microsoft MSXML Parser onto your web server.

To install the 404 handler:

  1. Install the MSXML parser on the server, mentioned above.
  2. Install three files on your web server: 404.asp, 404.xml, and 404.dtd. These are linked below.
  3. Modify the strXMLDoc constant at the top of 404.asp to point to 404.xml
  4. Modify the 404.xml file to list the spiders that you do not want to have forwarded. Do not list spiders that you want to forward to the new page.
  5. Modify the 404.xml to list files that you want to have forwarded to a new location, listing the old local URL, and the new local or fully qualified URL.
  6. In Internet Service manager, configure the error handler to use your 404 handler as the page to display.

See these additional pages for the files and configuration dialog: