Search code examples
coldfusioncoldfusion-9application.cfc

Error page when someone accesses Application.cfc


I am just considering a scenario where someone might give Application.cfc in a url. I know this will not work as it is reserved by ColdFusion engine and user will see an error.

Is it possible to redirect user in such scenario?


Solution

  • I just successfully caught it with a site-wide error handler. Is that a viable solution for you?

    Small update, figured this out:

    <cftry>
        <cfif error.Message EQ "Invalid request of Application.cfm, Application.cfc, or OnRequestEnd.cfm file.">
            <cflocation url="#getContextRoot()#/#getDirectoryFromPath(error.Template)#">
        </cfif>
        <cfcatch>that didn't work</cfcatch>
    </cftry>