Is it possible to render a different page when the requested page does not exist using the OnRequestStart event handler?
function onRequestStart( string targetPage ) {
// handle another page
}
if(FileExists(cgi.script_name)){
include cgi.script_name;
}else{
// render another page
}
if I use the include directly instead of passing it through onRequestStart, I get an error about missing SESSION
If I don't abort the execution, I get the File not found
error. Is there a way to skip trying to find the file and use the onRequestStart event to render a different page?
If you are trying to prevent a 404 of a coldFusion page (e.g. /index2.cfm) where the cfm template doesn't exists you can use onMissingTemplate()
in your application.cfc
If the template that causes the 404 isn't something handled by CF (i.e .htm,.html) then you will have to catch it in the webserver using a custom 404 page or possibly a url rewite