0

I'm having problems with RewriteRule. My tomcat application is Xyz and it is placed in its folder on localhost. Server name is www.mydomain.com. Application can be reached with www.mydomain.com/Xyz, but I would like to reach it with www.mydomain.com. Is it possible to achieve this with RewriteRule?

I use JkMount within the Apache configuration file:

JkMount /Xyz worker1
JkMount /Xyz/* worker1

where worker1 is member of worker defined as:

worker.list=worker1
worker.worker1.type=ajp13
worker.worker1.port=8009
worker.worker1.host=localhost
worker.worker1.lbfactor=1

I tried to add to the Apache configuration file RewriteRule just before JkMount:

ServerName www.mydomain.com
RewriteEngine on
RewriteRule ^/(.+)$ /Xyz/$1 [L,PT]

but with no success. Application can be easily reached with www.mydomain.com/Xyz, but www.mydomain.com doesn't work at all. it just produces error message...

Any suggestions?

Zoran Kalinić
  • 317
  • 2
  • 10
  • 23

1 Answers1

1

If you are happy not to use URL rewrite you can achieve similar by defining ROOT context.

Detailed Tomcat Context documentation here

[ Note: didn't try this, will do later ] I'd suggest you move your move application to a directory outside of your /webapps, eg. /myapps/xyz/; and then add a file to define your application context (for Tomcat 7)

$CATALINA_HOME$/conf/Catalina/localhost/ROOT.xml 

for previous Tomcat version probably something like:

$CATALINA_HOME$/conf/ROOT.xml 

In ROOT.xml define where your application root (docBase) is and leave path element empty

<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
    <Context deployOnStartup="true" docBase="/myapps/xyz/" path="" reloadable="false">
    <Manager pathname=""/>
</Context>

Similar posts are here

Srecno

Community
  • 1
  • 1
Milan
  • 1,903
  • 17
  • 16