The 404.asp File |
Search [fhihfkie] |
||
Previous Next Xoc Software Training RVBA Conventions Maya Calendar Program Company Information Tools ASP.NET and Other Tips Articles Architecting, Writing, and Maintaining Large Programs in Visual Basic MiscellaneousConstructing a 404 Handler for IIS Constructing a Links Page using XML Differences between XHTML 1.0 and HTML 4.0 ECMA, ISO, IETF RFCs, and Other Standards Home Automation Cataloging a Library Implementing a Privacy Policy Using P3P Mining Web Server Logs Object Oriented Programming Concepts Recommended Computer Books Recommended Internet Explorer Settings Review of the Compaq iPaq 3800 Series: H3830, H3835, H3850, H3870, H3875 Things to Consider when Internationalizing an Application Understanding the Internet Jigsaw Puzzle Using the Localization Toolkit Xoc Scale Search Engine Ratings Foldit Temporary Download Site Downloads Links Search Other Xoc managed sites: http://grr.xoc.net http://www.986faq.com http://www.mayainfo.org https://mayacalendar.xoc.net http://www.yachtslog.com |
<%@ Language=VBScript %> <% '404 Handler 'Written by Greg Reddick 'http://www.xoc.net/works/404handler Option Explicit Const strXMLDoc = "/_site/404.xml" Sub Redirector() Dim strRequest Dim strAbsUrl Dim dom Dim nod Dim strNew Dim strIp strRequest = Request.QueryString strAbsUrl = LCase(Mid(strRequest, Instr(Instr(1, strRequest, "://") + 3, strRequest, "/"))) set dom = Server.CreateObject("msxml2.domdocument") dom.async = False dom.validateOnParse = False Call dom.setProperty("SelectionLanguage", "XPath") If dom.load(Server.MapPath(strXMLDoc)) Then 'See if we're dealing with a spider (which we don't forward) strIp = Request.ServerVariables("REMOTE_ADDR") Set nod = dom.selectSingleNode("/descendant::ip[attribute::address='" & strIp & "']") If nod Is Nothing then 'See if there is an address to forward Set nod = dom.selectSingleNode("/descendant::url[attribute::old='" & strAbsUrl & "']") If Not (nod Is Nothing) Then strNew = nod.attributes.getNamedItem("new").value Response.Status = "301 Moved Permanently" Call Response.AddHeader("Location", strNew) Call Response.Write("<html><head><title>Object moved</title></head>") Call Response.Write("<body><h1>Object Moved</h1>") Call Response.Write("This object may be found at <a href=""" _ & strNew & """>" & strNew & "</a>.") Call Response.Write("</body></html>") Call Response.End End If End If Else Call Response.Write(XMLError(dom.parseError, strXMLDoc)) End If set nod = Nothing Set dom = Nothing End Sub Function XMLError(parseError, strUrl) XMLError = "Error Code: " & CStr(parseError.errorCode) _ & "<br />File Position: " & CStr(parseError.filepos) _ & "<br />Line: " & Cstr(parseError.line) _ & "<br />Line Position: " & Cstr(parseError.linepos) _ & "<br />Reason: " & Server.HTMLEncode(parseError.reason) _ & "<br />Source Text: " & Server.HTMLEncode(parseError.srcText) _ & "<br />URL: " & Server.HTMLEncode(parseError.URL) _ & "<br />" End Function Call Redirector() Response.Status = "404 File not found" %><?xml version="1.0" encoding="UTF-8" standalone="no" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>The Page Cannot be Found</title> <meta name="robots" content="noindex"></meta> <style> <!-- BODY { FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif } H1 { COLOR: #cd5c5c } H2 { COLOR: #cd5c5c } TABLE { WIDTH: 540px } --> </style> </head> <body> <table> <tr> <td> <h1>The Page Cannot be Found</h1> <hr /> <h2>Cause:</h2> <ul> <li>The requested file has been deleted.</li> <li>The requested file has never existed.</li> <li>The requested file is temporarily unavailable due to maintenance, upgrades, or other similar reasons.</li> <li>The requested file has moved, and we didn't automatically forward to the new page.</li> </ul> <hr /> <h2>Please try the following:</h2> <ul> <li>If you typed the page address into the web browser, make sure that you spelled it correctly.</li> <li>Open the <a href="/">home page</a> of this site.</li> <li>Click the Back button to try another link.</li> <li>Try <a href="/search.asp">searching</a> for something related to the original topic of the page.</li> </ul> <hr /> <h2>HTTP 404 - File not found</h2> </td> </tr> </table> </body> </html> |
||
Top |
[www.xoc.net] Copyright © 1997-2023 by Gregory Reddick . All Rights Reserved. 02/20/09 01:28 |