Steven Erat's Blog Steven Erat Photography
 
 
Viewing By Entry
 
 

TalkingTree  Configuring ColdFusion to process requests with custom file extensions

 

Technote 18289 describes how to configure ColdFusion MX to handle custom template extensions such as .dbm. The technote is outdated and this blog entry will show you how to configure a custom extension for ColdFusion MX 7. On some occasions I've been asked how to alter the template extension handling in order to mask that ColdFusion runs the web application, so this procedure could be used to even map .htm extensions to ColdFusion.

  • Configure the webserver by using the wsconfig.jar's -map switch with a comma separated list of extensions in quotes, such as -map ".htm,.html". ColdFusion ships connector installation scripts in the cf_root/bin/connectors/ directory that can help facilitate using the wsconfig utility. You could edit the script IIS_connector.bat provided for you so that it uses the -map switch like this:
    %CFUSION_HOME%\runtime\bin\wsconfig -server coldfusion -ws IIS -site 0 -coldfusion -cfwebroot -map ".htm,.html" -v
  • After using wsconfig with the -map switch or using the modified IIS_connector.bat script, the web server is configured to send those extensions to the ColdFusion server, but CF has no internal mapping for them to associate them with the underlying engine, the CFMServlet.
  • If a request for index.htm was made at this point, IIS would hand off the request to the connector, but the connector would have a list of mappings that it got from ColdFusion's web.xml file, and since web.xml does not yet contain mappings for .htm, the result will be that the connector returns an HTTP 503 status code to the web server and the web server sends that to the client browser.
  • Add the internal mappings by backing up and then editing cf_root/wwwroot/WEB-INF/web.xml to create new custom mappings that associate the extensions with the CFMServlet.
  • Use an existing mapping from web.xml as a starting point, like this one:
    <servlet-mapping id="macromedia_mapping_8">
       <servlet-name>CFMServlet</servlet-name>
       <url-pattern>*.cfm</url-pattern>
    </servlet-mapping>
  • Just after the last servlet-mapping node, copy the starter code into the file, and then and change the *.cfm extension in the url-pattern element to a custom mapping like *.htm or even *.foo, and finally remove the id attribute:
    <servlet-mapping>
       <servlet-name>CFMServlet</servlet-name>
       <url-pattern>*.htm</url-pattern>
    </servlet-mapping>
  • Then copy and paste that custom mapping to create a variation on the URL Pattern, ending in /* like this:
    <servlet-mapping>
       <servlet-name>CFMServlet</servlet-name>
       <url-pattern>*.htm/*</url-pattern>
    </servlet-mapping>
  • Repeat for each custom mapping such as .dbm, .htm, etc... Each custom mapping will require two servlet-mapping nodes, one for *.ext and another for *.ext/* (where the *.ext/* mapping helps map Search Engine Safe URLs such as /blog/index.cfm/2006/2/17/CF-Custom-File-Extensions for example)
  • Save web.xml
  • Restart the ColdFusion server AND restart the web server.

 


Comments

Btw, the url pattern doesn't need to contain a file extension. Actually, the url pattern can also be a "directory": /foo/*. This way you can easily create URL that look like deep links but are actually passed to one single CF page.


hey... thats what i said :)

http://www.revolutionwebdesign.com/blog/index.cfm?...

funny how its ALMOST the same entry.


All I get is the following error:

Error Occurred While Processing Request
/ by zero

Anyone else receive this error?


I have tried this and can verify that this does work...but has anybody verified whether or not the security sandbox still operates correctly on these file types. As far as I can tell, it breaks it.


Wow - very impressive site Steven. Thank you - for the resources!!
I'd suggest it's worth mentioning that the 1st step above would configure the server to give ALL *.xml file requests to ColdFusion for processing. I myself reserve CF processing of *.xml files for very special cases. Thus I use the entries you show in the web.xml file but configure each directory individually as required in IIS. For example the default behavior for http://somesite.com and its subdirectory's where one may or may not find static *.xml files. But then add the jrun executable for the extension *.xml on the directory \XML in IIS.


Brian,

Where you say "to give ALL *.xml file requests to ColdFusion", I think you mean .htm file requests (not .xml) since that's the example extension I used in the blog entry.

You're right that its possible to control extension mapping on a per directory level rather than globally. IIS can have the properties for directories and files override any inherited properties.


Thank you for your code sample, this is exactly what I was looking for. Any way to make it only process specific websites sites on the server and not all .html files on the server?


it's worth noting that you must cycle the IIS service after the web server mappings for the custom extension are added. The WSConfig GUI will prompt you to let it go ahead and restart the webserver, but it's good to know in the event that you ever find yourself doing this manually without wsconfig.


Guys, we have been using a custom file extension for years on a standard server install of CF7 and CF8 using the technique in this blog. I've recently begun preparing to setup a multi server environment in preparation for clustering but I'm finding that the custom file extension does not work. In my case I'm trying to to use .cfg instead or in addition to .cfm Has anyone got this to work in a muti-server configuration?

Despite updating the wed.xml file and updating IIS the log file still reports:

2009-07-29 23:58:43 jrISAPI[7096:188] ***HttpExtensionProc for JRun ISAPI Extension: uri is "/test.cfg"
2009-07-29 23:58:43 jrISAPI[7096:188] HTTP_HOST: ###.##.###.###
2009-07-29 23:58:43 jrISAPI[7096:188] filtering /test.cfg (/test.cfg) HOST=###.##.###.###
2009-07-29 23:58:43 jrISAPI[7096:188] filterRequest: no match
2009-07-29 23:58:43 jrISAPI[7096:188] ExecUrl: request received: URL=/test.cfg
2009-07-29 23:58:43 jrISAPI[7096:188] ExecUrl Completion: 503, URL=/test.cfg.

Any Ideas? Does it not work in Multi-Server mode?


Cross referencing a new, 2011 article by Charlie Arehart that is rather comprehensive, and includes things to think about when making these changes:

http://www.carehart.org/blog/client/index.cfm/2011...


yeah, after above fix in web.xml.
also restart your iis and CF service.


 

 

Calendar

 
Sun Mon Tue Wed Thu Fri Sat
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    

Search This Site

 
This is an exact search only

topics

 
adobe blogging coldfusion computer technology events flex java learning linux mac os x macromedia meetup new england odds & ends outdoors personal photos photoshop science travel video

About This Site

 
Adobe Alumni & Community Professional. Expert in ColdFusion, Flex, LCDS, Photoshop, Lightroom. Linux RHCE. Follow Me!. For my photography check out Boston Portrait Photographer.

Speaker at CF.Objective(): Automated UI Testing with CFSelenium, MXUnit, ANT, and JenkinsCI

Adobe Community Professional (ACP)
Red Hat Linux Certified Engineer

Recent Entries

 
Automated System Testing for ..
Could not find ColdFusion com..
No April Fools: Selenium Ship..

Recent Comments

 
Posted By Steven Erat:
Jim, and anyone else that may attend, if you would like the full slide deck and my demo project files BEFORE the conference, please reply as a comment ...

Posted By Jim Priest:
Can't wait for this one!!

Posted By iPhone Repair:
It appears there are so many people have issue with their iPhone & iPod Touch screens dropped and cracked. It happened to me also when u haven't got a ...

recently played

 
Mr. Brightside
by The Killers
on Hot Fuss
Get Hot Fuss by The Killers on Amazon

now playing, a plug-in for itunes

Categories

 
RSS Adobe (34)
RSS Bicycling (9)
RSS Blogging (39)
RSS Books (13)
RSS Breeze (13)
RSS CFMX Podcasts (10)
RSS ColdFusion (437)
RSS Computer Technology (51)
RSS Events (26)
RSS Flex (20)
RSS Gadgets (11)
RSS HiTech Industry (16)
RSS Java (26)
RSS Learning (57)
RSS Linux (70)
RSS Mac OS X (23)
RSS Macromedia (27)
RSS Meetup (35)
RSS New England (62)
RSS Odds & Ends (25)
RSS Outdoors (32)
RSS Personal (29)
RSS Photos (111)
RSS Photoshop (29)
RSS Podcasts (18)
RSS Rants (19)
RSS Restaurants (8)
RSS Science (34)
RSS Spain (16)
RSS Travel (42)
RSS Twitter (10)
RSS Video (20)
RSS Webcam (3)
RSS Writing (10)

RSS

 


Add to Google
Add to My Yahoo!

Credits and Stuff

 
BlogCFC - Free ColdFusion Powered Blog Software


 
 
blog | photos | flickr | referers | webcam | stats | about | contact
 
Copyright © 2012 Steven Erat. All rights reserved.
This is a personal weblog. The opinions expressed here represent my own and not those of my employer