Tomcat Virtual Directory Howto

July 03, 2019

Let's create a Tomcat virtual directory (or Alias) called /my_scripts which points x:\cf\cfusion\wwwroot\cf_scripts\scripts\ by adding the following inside of a <Host> tag in the server.xml file:

<Context path=""
    <PreResources base="x:/cf/cfusion/wwwroot/cf_scripts/scripts"

A few things to note:

  • Take a backup of server.xml first, if you end up with invalid XML or configuration the server will not start up again until you fix it.
  • You will need to restart Tomcat / ColdFusion for the change to apply
  • Note that I am using / forward slashes in the paths to avoid escaping backslashes.
  • Assumes my tomcat webroot is x:/cf/cfusion/wwwroot
  • Assumes my tomcat temp directory is: x:/cf/cfusion/runtime/conf/Catalina/localhost/tmp
  • Assumes I'm using Tomcat 8.5 or greater (eg CF2016+)

The syntax for creating a virtual directory in Tomcat changed in Tomcat 8.5, if you are using Tomcat 8, Tomcat 7 (CF10 or CF11) or below you will need to use a syntax like this:

<Context path=""

Like this? Follow me ↯

1 person found this page useful, what do you think?


Thank you very much for this bit; it helps a lot if you erraneously have changed the script directory in cfadmin, forgetting that the admin uses the built in webserver and not iis ... ;-)

Post a Comment


Foundeo Inc.