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:
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:
<!DOCTYPE jrun-web-app PUBLIC "-//Macromedia, Inc.//DTD jrun-web 1.0//EN"
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:
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:
Well, that’s it for today. Hope it helps. Let me know.