(c) 2002 Visual Studio Magazine 
Fawcette Technical Publications

Issue: February 2002
Section: Online
Author: Jonathan Goodyear

ASP, VBScript	Create a Custom 404 Error Page
Listing 1	Customize the 404/Page Not Found page in IIS so that it performs double-duty. Determine from the URL path whether the browser has requested an article. If so, re-direct the browser to the real article URL. If the requested page is truly an error, display a "Page Not Found" message to the user.

<%@ Language="VBScript" %>

<%
Dim path, column, year, month, day

'get the path of the file that was originally 
'requested
path = Split(Request.QueryString, ";")(1)

'determine if the user is navigating
'to an article
If Instr(1,path,"/articles/") > 0 Then
	'split the path into components
	parts = Split(path,"/")
	
	'extract the article info
	column = parts(4)
	year = parts(5)
	month = parts(6)
	day = parts(7)
	
	'redirect the browser to the
	'real url
	Response.Redirect("/article.asp" & _
		"?column=" & column & "&year=" & year & _
		"&month=" & month & "&day=" & day)
Else
	'Display custom 404 message
	Response.Write("The " & _
		"following page could not " & _
		"be located on our server:" & _
		"<br><br>" & path)
End If
%>
