Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 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

share|improve this answer
    
thank you, this works, I added a RewriteRule to get to the first servlet: "RewriteRule ^/$ /index [R]", however, when in a servlet I call "response.sendRedirect("my-servlet");", it adds the /MyApplication prefix again. Maybe I should call "response.sendRedirect("/my-servlet"); –  stivlo Feb 1 '11 at 10:00
    
I don't know about response.sendRedirect but I suspect it returns a relative URI. Tomcat doesn't know about the RewriteRule. Another option is to deploy your application as ROOT.war with "JkMount /* ajp13_worker" in the apache config. Tomcat will still redirect requests to other applications, but will recognize your servlets in the "/" path. –  dialt0ne Feb 1 '11 at 13:43
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.