As you may know, when you request a CFM file that doesn't exist, you don't get the normal 404 error page that you may have setup in your web server, instead you get a CF error. This is simple enough to solve in IIS, you simply tell the server to ensure scripts exist in regards to cfm processing.
However - how is this done for Apache?
Edited: I know about the missing handler setting in the CF admin, however, this is for a box with N virtual servers on it and I'd want a different 404 handler for each server.
Archived Comments
Ray,
Can't you just set a Missing Template Handler to point to your 404 template in the CF Administrator?
Sorry, I should have been more clear. This is for a box w/ N servers on it. I'll update the entry to say so.
Ray,
I'm assuming that you are using Apache with Virtual Hosts for each website (I can't imagine another way to get them to work, actually) That said, put this inside each virtual host container:
ErrorDocument 404 "http://mysite.com/404.cfm"
Here is more documentation about that feature:
http://httpd.apache.org/doc...
That doesn't work though - it suffers the same problem as IIS (before you tweak it) - CF "grabs" the CF request and throws the error. If you request a HTML file that doesn't exist, then it works fine.
Ray,
are you attempting to pass are requests back via a single .cfm file for a CMS or something similar?
Ahh, yeah, that's not a surprise.
The only thing I can suggest is adding a Missing Template Handler in CF, and let that file actually decide what is the correct 404 page to include based off of host headers since you're probably running all of the sites off of one CFMX instance. Maybe just a simple cfswitch based off of cgi.http_host or something to that effect.
Because a default install of CFMX is basically only running single JRun listener & Application, I wouldn't think there is a way to do it other than what I mentioned above.
Brandon: Actually, I considered that, but the error document specified in CF will only fire when I use the default host, not one of the virtual hosts.
Jared: No, this is a simple attempt to get xxx.cfm, where xxx.cfm isn't a real file, to fire the Apache 404 handler, not the CF one.
In my tests on my local machine with virtual hosts I have found that if you put /errors/404.cfm in the missing template setting in the CF admin it will execute that path in relation to the current host that is being accessed. So if in the webroot of each of your virtual hosts you had a errors/404.cfm file that would get displayed as the 404 page for that host. This also works for the error handler. I found a cf-talk thread on this subject that clued me in that this was possible. It is pretty cool actually. I just wish I could do more cfml on the missing template handlers.
Ah here is the cf-talk thread that clued me in:
<a href="http://www.houseoffusion.co...">http://www.houseoffusion.co...
Hmm, interesting.. what do you get back when you are using one of the virtual hosts for a 404 status page? What if you set a default error handler document and try them across the various hosts-- does it work on all virtual hosts?
Sorry, I only have access to one Apache server w/ CFMX to play with this myself, but it's on a private network at home which I can't access from here.
Also, I assume that you know for sure that CFMX is working properly on all of the virtual hosts? Just checking.
Yep Kurt, you're right. I should of known that given that I wrote a blog entry about error templates over a year ago. ;)
http://devnulled.com/archiv...
Kurt, this is what I had (although my path was /404.cfm). I will give it one more try though.