[thelist] emailing reports of 404 errors to myself

Ross DeMeyere ross at demeyere.com
Fri Apr 21 09:55:42 CDT 2006


create a custom 404 page (that will handle everything but the .cfm files)

some of the variables in the file are defined in the `Application.cfm`
TDY is a boolean that is true when I am gone, and false whey I am here, so I
don't get error messages when I am gone. (Temporary DutY).

This doesn't work for .cfm files, but you can handle that from the
`Application.cfm`, I just haven't done that yet.

You might want to take out the `and (not ("#myDomain#" is MY_IP_ADDRESS))`
if you are testing this yourself.

I Hope this helps.

//////////////////////////
<!--- 404.cfm for demeyere.com --->
<!--- note: this does NOT work for .cfm templates that are 404...
      they will break in place with a CF template not found error --->

<cfset myNewURI="" >
<cfset myPath = CGI.QUERY_STRING >
<cfset myPath = lcase(REReplace(myPath,
"404;http://#CGI.SERVER_NAME#:#CGI.SERVER_PORT#" , "" , "All")) >
<cfset myDomain = lcase(CGI.SERVER_NAME) >

<cfswitch expression="#myPath#">
  <cfcase value="/extra/contact.html,/contact.html" ><cfset myNewURI = "
http://demeyere.com/contact/" ></cfcase>
  <cfcase value="/convertunits.asp" ><cfset myNewURI = "
http://www.google.com/help/features.html##calculator" ></cfcase>
  <cfcase value="/comsec/pgp_public_key.asp" ><cfset myNewURI = "
http://demeyere.com/comsec/pgp_public_key.cfm" ></cfcase>
  <cfcase value="/default.asp,/default.aspx" ><cfset myNewURI = "
http://demeyere.com/" ></cfcase>
  <cfcase value="/webdesign/capabilities.asp" ><cfset myNewURI = "
http://demeyere.com/webdesign/services.cfm" ></cfcase>
  <cfcase value="/webdesign/entity.asp" ><cfset myNewURI = "
http://demeyere.com/webdesign/entity.cfm" ></cfcase>
  <cfcase value="/macr/photography01.htm" ><cfset myNewURI = "
http://rossmania.com/photoblog/" ></cfcase>
</cfswitch>

<cfif find("msnbot", CGI.HTTP_USER_AGENT) is not 0><cfset myNewURI = "
http://demeyere.com/"></cfif>

<cfif find("/mps/", myPath) is not 0><cfset myNewURI = "
http://archive.demeyere.com#myPath#"></cfif>
<cfif find("/pm/", myPath) is not 0><cfset myNewURI = "http://demeyere.com/
"></cfif>
<cfif find("/photoblog/", myPath) is not 0 and find("default.asp", myPath)
is not 0><cfset myNewURI = replace(myPath, "default.asp", "") ></cfif>

<!--- handle other 404 requests --->

<cfif myNewURI is "" >
  <cfswitch expression="#myDomain#">
    <cfcase value="rossmania.com,www.rossmania.com" ><cfset myNewURI = "
http://rossmania.com/photoblog/" ></cfcase>
    <cfcase value="amberink.com,www.amberink.com" ><cfset myNewURI = "
http://amberink.com/domainforsale/" ></cfcase>
    <cfcase value="ourgoodshepherd.org,www.ourgoodshepherd.org" ><cfset
myNewURI = "http://ourgoodshepherd.org/domainforsale/" ></cfcase>
    <cfcase value="w0ftx.com,www.w0ftx.com" ><cfset myNewURI = "
http://w0ftx.com/" ></cfcase>
    <cfdefaultcase><cfset myNewURI = "http://demeyere.com/"
></cfdefaultcase>
  </cfswitch>

<!--- mail iff other 404, id est, do it in this cfif while not TDY --->
<cfif (not TDY) and (not ("#myDomain#" is MY_IP_ADDRESS)) >
 <cfmail
 to="error at demeyere.com"
 from = "error at demeyere.com"
 subject = "[error 404] #myDomain##myPath#"
 server = MY_MAIL_SERVER
 replyto = MY_CONTACT_EMAIL
 ><cfmailparam name="X-demeyere-support" value="404"><cfmailparam
name="X-demeyere-priority" value="routine">
404 ERROR: http://#myDomain##myPath#

CGI.QUERY_STRING: #CGI.QUERY_STRING#
CGI.REMOTE_HOST: #CGI.REMOTE_HOST#
CGI.SERVER_NAME: #CGI.SERVER_NAME#
CGI.SERVER_PORT: #CGI.SERVER_PORT#
CGI.HTTP_REFERER: #CGI.HTTP_REFERER#
CGI.HTTP_USER_AGENT: #CGI.HTTP_USER_AGENT#

#demeyereUUID("#CGI.REMOTE_HOST#")#

NNNN
</cfmail>
</cfif>
</cfif>

<!--- redirect to myNewURI --->
<cflocation url="#myNewURI#" addtoken="no" >


////////////////// end of code  //////////////////////////////////

--------------------------------------------------
Ross DeMeyere
DeMeyere Design Incorporated
http://demeyere.com/

rossMania
a photo journal - the other side of DeMeyere Design
http://rossMania.com/



More information about the thelist mailing list