By Peter Bell

Processing .html files using ColdFusion - on a Mac or a PC

In the category of "post so I don't ever have to Google it again", here are the steps required to process .html files in ColdFusion . . .

1. Update web.xml
In ColdFusion (e.g. #CFUSIONROOT#\wwwroot\WEB-INF\web.xml in windows or under JRUn on a Mac, in /Applications/JRun4/servers/cfusion/cfusion-ear/cfusion-war/WEB-INF/web.xml) add the following xml:

<servlet-mapping id="macromedia_mapping_14">
<servlet-mapping id="macromedia_mapping_15">

Note that the 14 and 15 should be unique (and I make them sequential - I *think* that matters) so if you have 9 mappings, these would be _10 and _11.

Then Restart CF.

2. Update Web Server
In IIS6, go into site properties, click on the "home directory" tab, click on the configure button, under mappings, select and "edit" the .cfm record and copy the value of "executable". Cancel out of that, Add new mapping, paste the executable value, put ".html" into the extension and hit OK (leave as all verbs).

In Apache 2.x on a Mac (should be same elsewhere) I went into httpd.conf. I found a line that said AddHandler jrun-handler .jsp .jws .cfm .cfml .cfc .cfr .cfswf (search for .cfm). I added .html to the end of the list giving:

AddHandler jrun-handler .jsp .jws .cfm .cfml .cfc .cfr .cfswf .html

I then restarted Apache (in Terminal sudo apachectl restart - enter root password when requested).

Tested and working.

Tested this on the home test box, Yes it is working 100%, Thankyou

WinXP, CF7, IIS6

Only shortage now for me is DW8 does not recognise ctml code for html page so does not include in dropdown list, but there are ways around it.
# Posted By Kent | 3/31/07 6:50 PM
I have a few guesses, but what are the benefits of doing this?
# Posted By Ben | 3/31/07 9:09 PM
@Kent, Glad it's working for you!

@Ben, Primarily decoupling the URL interface to a website from the programming language it happens to be built in.
# Posted By Peter Bell | 3/31/07 11:07 PM
@Ben, one of the benefits of doing it is that using an .html extension gives hackers one less clue as to which application server that you're using.
# Posted By Tom Mollerus | 4/4/07 4:54 PM
Is it possible to set the url-pattern to match a specific URL? Or will it just match the directories and files after the URL?

We have a mulithomed CF server on IIS 6 and I'd prefer to have this only work on one of the sites so that the HTML files in other sites are not all sent through ColdFusion before being sent out.
# Posted By Dave | 4/12/07 8:21 PM
Hi Dave,

I'm not sure in Apache. In IIS 6 you can definitely set these properties at a site level, but I'm not sure you can make it any more granular than that.
# Posted By Peter Bell | 4/13/07 10:06 AM
Hi Peter,

Yes, I thought so too. But even though I've only added the HTML extension to be processed by ColdFusion for one IIS site, all my other sites on that server are also processing the HTML files as CFM.

By the way, I'm testing this out on CFMX 6.1, not 7
# Posted By Dave | 4/13/07 2:22 PM
Hmmm. Shouldn't be a 6.1/7 thing as this is a web server - not CF thing. I'd just double check your configuration. Only other thing (a hack, but it works) - put an appliction.cfm in the root of your other projects with <cfsetting enableCFOutputOnly="No" >. That way, even if cf is processing the files it will still display regular HTML. Obviously thats a bit of a hack - if you have lots of large traffic html sites you probably don't want cf having to handle all the requests - even if it does spit back the right html.

Sorry I couldn't be of much more help. Let me know if you figure this out (and out of interest, what version of what OS and what version of what web server are you running?)
# Posted By Peter Bell | 4/13/07 2:35 PM
You'll be glad to know this still works on version 8 - substituting "coldfusion" for "macromedia" in the mapping name (I didn't try using macromedia, but followed the convention of the rest of the mappings).

They had the mapping for RDS commented out, so not sure if skipping a number would make a difference really.

Cheers. (Was kind of neat that this was the first page to show up when I searched google)
# Posted By Sammy Larbi | 8/18/07 1:04 PM
Hi Sam,

Good timing! I just installed the CF8 final release on my laptop so I was also going through this yesterday! As you said, seems to work well in CF8.
# Posted By Peter Bell | 8/19/07 12:10 PM
Thanks for the tip Peter.

Unfortunately I'm having the same issue as Dave above - although the .html extension has only been added for one site, Coldfusion is now processing .html files for all sites.

Anyone found a way round this?
# Posted By Brian | 6/2/08 2:50 PM
Question: I was using built in server on my macbook pro, do I have to worry about Apache edit of http config file?

Also this is a great way to set up a page with cf and html and allow client to connect with contribute to allow them to edit the page content but none of the cfml!!
# Posted By Alfio Raymond | 6/24/08 1:49 PM
BlogCFC was created by Raymond Camden. This blog is running version 5.005.