In Apache Tomcat, if we want to add a sub directory into an url, such as vicker313.wordpress.com/subdir, we will normally create a new directory at the [tomcat]\webapp directory, and put in the necessary web pages.
However if we need to put the web pages outside webapp, then we need to create a virtual directory in Tomcat:
- Go to [tomcat]\conf\Catalina\localhost (version that I used is 5.5).
- Create a xml file, named it as the name of the directory that store your web pages, for example subdir.xml.
- Put in the following code (assume your directory is c:\subdir):
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/subdir" docBase="c:/subdir" debug="0" privileged="true"></Context>
- Now you can access the site http://www.yoururl.com/subdir
It is also possible to point the virtual directory to a shared folder of another machine:
<Context path="/subdir" docBase="//192.168.1.2/subdir" debug="0" privileged="true"></Context>
Beware that the directory that you point must have the web pages, as lease an index.html. Or else it will just show out no resource error message (will not list out the content of the directory).