Private Function stripEndSlashes(strURL, Optional strEnd = "L") strEnd = UCase(Trim(strEnd)) Select Case strEnd Case "L": If (Left(strURL, 1)="/") OR (Left(strURL, 1)="") Then stripEndSlashes = Mid(strURL, 2, Len(strURL)) End If Case "R": If (Right(strURL, 1)="/") OR (Right(strURL, 1)="") Then stripEndSlashes = Mid(strURL, 1, (Len(strURL)-1)) End If Case Else: stripEndSlashes = strURL End If End Select End Function strSiteURL = "http://example.com/" 'Full URL of the Website strSiteURLR = "/" 'Relative Path for use in Server.Transfer str404 = Trim(Request.ServerVariables("QUERY_STRING")) 'check if its a 404 error or a direct request If Left(str404, "3")="404" Then 'its a 404 error, so parse it baby!! strURL = stripEndSlashes(Mid(str404, 5, Len(str404)), "R") strFileUrl = stripEndSlashes(Mid(strURL, Len(strSiteURL), Len(strURL)), "L") strFile = Mid(strFileUrl, 1, (InStr(strFileUrl, "/")-1)) strParam = stripEndSlashes(Mid(strFileUrl, (Len(strFile)+1), Len(strFileUrl)), "L") strRedirect = strSiteURLR & strFile & ".asp" Session("pageParam") = strParam Server.Transfer(strRedirect) Else Response.Write("404 - Page Not Found") Response.End End If