Ok.. So now I've found that my previous code would not work for
sub-dir's.. So I rewrote it...

Use as follows:

- Place the code below into a 404.cfm file, located in the wwwroot of
the default site on the IIS5/CFMX server.
- Set the "Missing Template Handler" in CFMX to "/404.cfm"
- Your clients can then put a file called "404.cfm" into the root of
their websites, which will be displayed if the server cannot find the
CFM file the visitor entered into the browser... As opposed to the
unfriendly 404 error message sent out by CFMX.

**WARNING BEFORE YOU USE THIS CODE**

- This code will look in the ROOT of the clients web for the 404.cfm
file.
- It relies on the URL to translate into a path, exactly.  I.e.,
www.yourdomain.com/dummy/something/hello.cfm should translate to (as an
example) "D:\www\hosts\yourdomain\dummy\something\hello.cfm".  So.. If
you've created a virtual directory, and that doesn't coincide with the
above schema example (of course your root dir name and drive will be
different), than it will fail - AND MAY CAUSE BIZARRE RESULTS.  So BE
CAREFUL and TEST, TEST, TEST, before you use this!!
- Of course, this will only work for missing .CFM files.  Has nothing to
do with other extensions (.htm, .asp, etc.) which you'll need to adjust
within IIS.

Hope this is helpful to others.  Feel free to modify it and make it
better - so long as you share with me what you did to make it better!
:)


============

<!--- Strip the extraneous path crud from the path and return it in a
var --->
<cfset urltrans = "#replace(cgi.path_translated, replace(cgi.PATH_INFO,
'/', '\', 'ALL'), '')#">

<!--- See if the file "404.cfm" exists in the root of the website being
called --->
<cfif FileExists("#urltrans#\404.cfm")>

        <!--- If so.. Go get the 404.cfm file for the browser and
deliver it up! --->
        <cfhttp url="http://#cgi.SERVER_NAME#/404.cfm"/>
        <cfoutput>#cfhttp.FileContent#</cfoutput>

<cfelse>

        <!--- Otherwise.. Deliver up something generic --->
        <whatever you want to show here if they don't have a 404.cfm
file -- can be html.. etc.>

</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
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Reply via email to