Copy link to clipboard
Copied
When using the built in web server, is there a way to specify a different error handler when you try to access a NON .CFM file? Right now I get the standard:
java.io.FileNotFoundException: filename.ext
Is there any setting to override this and direct the message to your own .cfm template? The missing template handler in the CF Admin work only for .cfm files.
Thx
Copy link to clipboard
Copied
I think that it is so by design. ColdFusion is configured to process files with extensions .cfm, .cfc, .cfml, .cfr, .jsp, and so on. If the extension of the requested file is not in this list, for example filename.ext, the request will pass to the web server for handling. So, even if it is possible for you to customize the 404 handler (and it usually is), you will have to do so in the (XML) configuration files of the web server.
Copy link to clipboard
Copied
Do you know how/where to change this using Coldfusion's built in webserver?
Copy link to clipboard
Copied
It depends on version. What's your ColdFusion version?
Copy link to clipboard
Copied
Coldfuion Version 8
Copy link to clipboard
Copied
The in-built web server for ColdFusion 8 is JRun. I am on ColdFusion 10, however, and so cannot offer hands-on advice. (CF10 replaced JRun with Tomcat.)
My guess is that you have to modify the file {CF_ROOT}/WEB-INF/web.xml. Don't forget to create a back-up first!
You may then proceed as follows.
1) In the ColdFusion root (CF_ROOT), create the file myCustomFileNotFound.cfm. Give it some content, like
My custom File Not Found page. Current time: <cfoutput>#now()#</cfoutput>
2) Open the file {CF_ROOT}/WEB-INF/web.xml in a text editor. Add the following error-handling specification just before the end tag </web-app>:
<error-page>
<error-code>404</error-code>
<location>/myCustomFileNotFound.cfm</location>
</error-page>
Save the file web.xml.
3) Restart ColdFusion. Test by browsing to a URL requesting filename.ext