Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Custom 404 error

Status
Not open for further replies.

osbel

Programmer
Sep 17, 2001
26
US
I am working on an application that needs to log some user activity. We would like to be able to run a coldfusion file when a 404 error is encountered so we can get a record of what pages couldn't be found. Is there any way to do this and to have it specific to just on app running on a coldfusion server? Thanks.
Leslie
 
Not sure of your excat details but the process of setting up a 404 is easy.

If you are running IIS, select the domain you are hosting and under properties Custom Errors, scroll down and asign 404 to be associated with a URL, specifically a 404.cfm page.

Then just have the 404.cfm page do some auditing.

1st, have the page log info like:

Page requested: #cgi.QUERY_STRING#
Refered By: #cgi.HTTP_REFERER#
Request Method: #cgi.REQUEST_METHOD#
Path Translated: #cgi.PATH_TRANSLATED#
Path Info: #cgi.PATH_INFO#
Browser: #cgi.HTTP_USER_AGENT#
Accept: #cgi.HTTP_ACCEPT#

You could have the above info put into a Database or CFMAIL it to yourself.

You could also do some smart 404ing by checking what they were looking for...

\-------
<cfset search_word = listlast(cgi.QUERY_STRING,&quot;/&quot;)>
<cfset dot= find(&quot;.&quot;, search_word)>
<cfif dot neq 0>
<cfset search_word = left(search_word, len(search_word)-dot)>
</cfif>
------
search_word could them be compared to a list of keywords in a database associated with a specific page url.

The possibilities are endless.

Smart 404s! Everyone should have on.

As for catching CF errors... It is best to use CFTRY and direct the users to fix their input. Don't assign a defualt CFERROR page in the administrator as it will be for all CF sites on that box.

Hope this helped you out...

------------------------------------------------------
Some good 404 resources are:

Here is a great article on 404s

Alaire has an awesome one:


-- David McIntosh
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top