OK. So I'm running CF on it's built-in server on my development system. On production I have a Virtual Directory setup with my hosting provider. This virtual directory houses many different things, all of which I need easy access to from either HTML pages or CF, so a CF mapping isn't an option.

For those of you unfamiliar with the concept let me just break it down real fast. I have images, stylesheets, scripts, etc. sitting in a folder on my machine, say "C:\mydirectory\of\resources", that I would like to be able to access from my code using a simple path, like "/mystuff/myimage.jpg". Oh yeah, did I mention (you probably saw this) that the path isn't even in my webroot?

So I could put an <img> tag in an html file like this:

view plain print about
1<img src="/mystuff/images/myimage.jpg" height="15" width="15" alt="test image" />

and it would properly render the image located at "C:\mydirectory\of\resources\images\myimage.jpg"

Now, there are tons of articles out there on how to create virtual directories in IIS or Apache, etc., but I could only find a single Macromedia (Adobe) Technote on how to create a virual directory when using CF’s built-in webserver.

Here’s the long and short of it. Within your [cfwebroot]/WEB-INF folder you will need to edit the jrun-web.xml file in your favorite (CFEclipse) editor. On a base level install it will probably look a little like this:

view plain print about
1<?xml version="1.0" encoding="ISO-8859-1"?>
2<!DOCTYPE jrun-web-app PUBLIC "-//Macromedia, Inc.//DTD jrun-web 1.0//EN"
3    "http://www.macromedia.com/dtd/jrun-web.dtd">

4<jrun-web-app>
5 <virtual-mapping>
6 <resource-path>/WEB-INF</resource-path>
7 <system-path>C:/CFusionMX/wwwroot/WEB-INF</system-path>
8 </virtual-mapping>
9</jrun-web-app>
(This particular layout is from my CF 6.1 instance. CF7 is slightly different.)
To add the new virtual directory you will need to create another virtual-mapping node. After having to play with this quite a bit (the technote didn’t do it justice) I found that the following worked best for me:

view plain print about
1<jrun-web-app>
2 <virtual-mapping>
3 <resource-path>/WEB-INF</resource-path>
4 <system-path>C:/CFusionMX/wwwroot/WEB-INF</system-path>
5 </virtual-mapping>
6 <virtual-mapping>
7     <resource-path>/mystuff/*</resource-path>
8 <system-path>C:/mydirectory/of/resources/</system-path>
9 </virtual-mapping>
10 <virtual-mapping>
11     <resource-path>/myotherstuff/*</resource-path>
12 <system-path>\\RemoteSrv\Networked\Computer\directory</system-path>
13 </virtual-mapping>
14</jrun-web-app>

This was great! Everything in the directory tree below those directories (subdirectories and all) is now available through the virtual directory mappings. So if I want to try:

view plain print about
1<cfimport prefix="ui" taglib="/myotherstuff/CustomTags/ui">
2<ui:incThis>
I can call the incThis.cfm file from "\\Remote\Networked\Computer\directory\CustomTags\ui"

Well, that’s it for today. Hope it helps. Let me know.

Cutter