Tomcat – How to map a web application to the root of a virtualhost

apache-2.2mod-jktomcat

I wrote a MVC Servlet + JSP web application and deployed in Apache+Tomcat. I don't call JSP directly, but I use them as view and I call them from the Servlets.

To make it visible in a virtual host, I mapped it using JkMount:

JkMount /MyApplication/* ajp13_worker

However now to access MyApplication I've to write URLs as

http://www.example.com/MyApplication/MyServlet

I would like to be able to call MyServlet from the root of my virtualhost such as in:

http://www.example.com/MyServlet

How do I do this?

Best Answer

How about:

RewriteEngine On
RewriteRule ^(/MyServlet.*) /MyApplication$1 [passthrough]

The passthrough will allow mod_jk to take the request after being processed by mod_rewrite