ColdFusion: difference between the CF Admin mappings and the virtual directories
Written on 21 March 2011, 03:05pm
This post highlights the difference between the ColdFusion Administrator Mappings section and the virtual directories.
The ColdFusion 8 and 9 Admin documentation pretty much explains everything (see highlighted note):
ColdFusion mappings let the cfinclude and cfmodule tags access pages that are outside the Web root. If you specify a path that starts with the mapping’s logical path in these tags, ColdFusion looks for the page using the mapping’s directory path.
ColdFusion also uses mappings to find ColdFusion components (CFCs). The cfinvoke and cfobject tags and CreateObject function look for CFCs in the mapped directories.
Note: These mappings are independent of web server virtual directories. If you would like to create a virtual directory to access a given directory through a URL, please consult your web server documentation.
So, the mappings defined in the CF Admin (
CFAdmin > Server Settings > Mappings) are defined so that ColdFusion is able to access pages outside of your web root. That’s because ColdFusion will not ‘see’ the virtual directories defined in your web server configuration.
Either if you use the JRun server, Apache or other flavors, the ColdFusion will not know anything about their configuration.
Let’s take an actual example: you have your ColdFusion 9 (web root
C:\JRun4\servers\cfusion\cfusion-ear\cfusion-war) running on JRun server. The jrun configuration file
C:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\jrun-web.xml contains the following virtual mapping to map ColdBox:
<virtual-mapping> <resource-path>/coldbox</resource-path> <system-path>C:/coldbox30</system-path> </virtual-mapping>
This tells the web server that when it receives requests for pages like /coldbox, it will serve the pages from the folder C:/coldbox30.
In the CF Admin, the mapping in the figure below will tell ColdFusion to look for included .cfm/.cfc files also in the mapped directory C:/coldbox30:
In conclusion, the CF Admin Mappings are for ColdFusion, while the virtual directories are for the web server.
Written by Dorin Moise (Published articles: 272)