One thing I'd recommend is doing something to trap missing images -
missing images toss 404 errors too, just not visible to the user. So you
can test for file extensions in the code, and if it's GIF or JPG or PNG
or whatever, you can use CFCONTENT to replace the image with a clear
gif.

I do a custom 404 template that tries to find a .htm, .html and .cfm
page that matches the user request, then tests for image extensions,
then puts the error in a database. Then each night at midnight I've got
a scheduled task that runs, grabs the errors, puts them into an email
and sends me my daily 404 Digest to pass out to developers to fix, trap
or whatever. It's really helped cut down on the number of missing links
and images people get from our applications.

We do the same thing with application errors - except those aren't
digested, they're instantly emailed to us and shoved into our project
manager so that we can catch errors as they arise and stay on top of
things. We then use the database of errors to track bug history and
template information. We can dump out a report on say Index.cfm that
shows all errors that have occurred in the template over time, as well
as any errors in included templates or tags that are called from
Index.cfm

Those global templates are pretty powerful if you make use of them.

Joshua Miller
Head Programmer / IT Manager
Garrison Enterprises Inc.
www.garrisonenterprises.net
[EMAIL PROTECTED]
(704) 569-9044 ext. 254
 
************************************************************************
*************
Any views expressed in this message are those of the individual sender,
except where the sender states them to be the views of 
Garrison Enterprises Inc.
 
This e-mail is intended only for the individual or entity to which it is
addressed and contains information that is private and confidential. If
you are not the intended recipient you are hereby notified that any
dissemination, distribution or copying is strictly prohibited. If you 
have received this e-mail in error please delete it immediately and
advise us by return e-mail to [EMAIL PROTECTED]
************************************************************************
*************


-----Original Message-----
From: Bob Haroche [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, December 12, 2002 10:58 AM
To: CF-Talk
Subject: Re: Custom 404 pages - catching invalid links


> I'm creating a custom 404 page.  I'd like to be able to catch the 
> invalid links that the users are typing in.
>
> Such as...
>
> The page you were trying to get, http://www.mysite.com/foo 
> <http://www.mysite.com/foo>  , was not found.  Etc....

Here's what I use for that:

<p>The page you requested, <CFOUTPUT><em>#ListLast(cgi.query_string,
";")#</em></CFOUTPUT>, does not exist or has been moved.</p>

----


And here's what I use to set up re-directions for old/moved pages and,
if no re-mapping already exists, to send an email alert for pages not
found.

This code is set up in a separate template and incorporated via
<CFINCLUDE> ias the first thing into the custom 404.cfm page.

HTH.

------------

<!--- Create re-mappings for old pages/new pages --->
<CFSET Redirects = StructNew()>
<CFSET Redirects["/old-page1.cfm"] = "/new-page1.html">
<CFSET Redirects["/old-page2.cfm"] = "/new-page2.html">

<!--- Determine page being requested, stripped of protocol and server
data ---> <CFSET pageRequest = "/" &
ListRest(ListRest(ListLast(cgi.query_string,
";"), "/"), "/")>

<!--- Redirect to new page if mapping exists --->
<CFIF StructKeyExists(Redirects,pageRequest)>
 <CFHEADER statusCode = "301">
 <CFLOCATION url= "http://#cgi.http_host##Redirects[pageRequest]#";>

<!--- Elsewise send webmaster a 404 alert --->
<CFELSE>
  <CFMAIL
    type="HTML"
    to="#ErrorEmail#"
    from="ErrorRobot@#cgi.http_host#"
    subject="Page Not Found: #ListLast(cgi.query_string, ";")#">
   <p>A requested file was not found on the #OrgShort# website</p>
   <p>-------------------------------------------------------</p>
  <p>URL Requested: #ListLast(cgi.query_string, ";")#<br>
      Error Date/Time: #DateFormat(Now(),"MMM D, YYYY")# at
#TimeFormat(Now(),"h:mm tt")#<br>
      Referring Page: <a
href="#CGI.HTTP_Referer#">#CGI.HTTP_Referer#</a><br>
      Browser Used: #CGI.HTTP_USER_AGENT#</p>
   </CFMAIL>
</CFIF>




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.

Reply via email to