404 custom error
Copy link to clipboard
Copied
I am running cf9 on Windows 2008 with IIS7 and I setup a custom 404 redirect. It works for .html files that don't exist but it does not work for .cfm files that don't exist. Very confused... can anyone help?
Examples
http://www.kyndoutdoors.com/idontexist.html (custom 404 works)
http://www.kyndoutdoors.com/idontexist.cfm (custom 404 does not work)
Copy link to clipboard
Copied
And you're setting them up on IIS, right?
IIS sends CF requests to the CF server, so you need to set up 404 handling there too.
--
Adam
Copy link to clipboard
Copied
Copy link to clipboard
Copied
The cfheader solution did not work. Adam, where in the CF Admin would I find a place to add a custom 404 redirect? Well I'm assuming you meant the CF Admin... If not, where in IIS?
Copy link to clipboard
Copied
Tried to add /404.cfm to the Missing Template Handler section of the CF Admin Server settings. No dice.
"The file specified as the site wide missing template handler does not exist. The default missing template handler will be used until a replacement is created."
Perhaps I need to better understand where they are referring to when the say "Specify the relative path to the template to execute when ColdFusion cannot find a requested template." I tried ../404.cfm, ../../404.cfm and so on until ../../../../../../../../../../404.cfm and still came up with nothing.
Frustration level increasing.
Copy link to clipboard
Copied
Ok finally got this one figured out. I had to copy/paste my 404.cfm file from my website's root folder into the following folder: c:/coldfusion9/wwwroot/
Once I did that, I went back into the cfadmin and added the following: /404.cfm to the Missing Template form field and it worked.
Tested and validated. Phew.
That was somewhat frustrating.
Copy link to clipboard
Copied
With all due respect, I'm not sure why you had so much trouble. Any ColdFusion book and countless websites explain how to do this relatively basic task.
A bit of Googling would have answered your questions.
Copy link to clipboard
Copied
Thanks Owain that was exceptionally helpful. I truly appreciate you taking the time to provide very useful feedback.
Let me point out though that out of the 6 CF books I have, none of them have any content on custom 404 redirects. And not only that, but even if you get the custom cf redirect down, you still have to deal with other types of missing pages like .html for example. That is an IIS issue, not a CF issue.
And when you say "countless websites" I beg to differ. Pretty sure you could count them if you wanted.
And lastly, a little bit of googling is a stretch. I googled quite a bit and it took googling the specific phrase in the CF Admin to finally find a solution. Most people's solution only covers the IIS part of it. 50% at best. That being said, usually the standard sites that come back in Google don't have the solutions. I find that I get my questions answered here and at devshed quicker than I do by googling and sifting through all the garbage.
Copy link to clipboard
Copied
Believe me I'm not trying to be facetious, I'm, just surprised you haven't come across anything saying about Application.cfc's and onMissingTemplate handlers - they're a pretty fundamental part of CF.
I completely agree that implementing a full customised solution that handles any document type is not simple, I'm just surprised you got to "../../../../../../../../../../404.cfm" before you found an answer.
Copy link to clipboard
Copied
Perhaps I need to better understand where they are referring to when the say "Specify the relative path to the template to execute when ColdFusion cannot find a requested template."
Actually I think it's Adobe who needs a better handle on their terminology here. A relative path does not work in that box; I need to put an absolute one.
My webroot for the site I am on is C:\webroots\shared\
My 404 handler is C:\webroots\shared\404.cfm
So if that option was after a relative path, then simply "404.cfm" should work as a value. but it doesn't. I need to specify "/404.cfm". That is not a relative path. I tried the more explicit relative path to the same location, "./404.cfm", but that still didn't work. The CFAdmin UI is simply getting CF's actually requirements wrong here.
But, anyhow, I saw your follow-up message. I was certainly able to plonk that 404 handler in my webroot, I did not need to put it in my CF root, like you seem to have. However are you sure your webroot isn't c:/coldfusion9/wwwroot/, and you're not merely using virtual directories and CF mappings to relocate your files to your "website root folder"?
Where is this different "website root folder" defined?
--
Adam

