You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Tim Diez <ti...@50below.com> on 2004/02/04 21:02:47 UTC

mod_jk and virtual folders?

Hello all, 

I've been searching high and low but I can't seem to find out how to do
the following.  I'm a newbie here so please bear with me.

I'd like to use apache and mod_jk to dynamically re-route all subfolders
of my httpd web server to a single Tomcat webapp.

I've got Apache running on port 80 with mod_jk configured to use tomcat
on the same box.  Tomcat is running on port 8080

http://www.myserver.com/
http://www.myserver.com:8080/mywebapp

Folders /foo and /bar don't exist, and I need them to point to
myserver.com:8080/mywebapp.

The tricky part for me has been setting this up to be dynamically
routed.  What I'd like to do is have myserver.com/<anyfolder> route to
myserver:8080/mywebapp, so I don't have to create a virtual host for
every potential subfolder on myserver.com:80/

So, I need http://www.myserver.com/*/hello.do?param=nada to map to
http://www.myserver.com:8080/mywebapp/hello.do?param=nada

I need the url to always keep the original host/folder.  I tried
mod_rewrite, but it changes the URL after the redirection.  If I use
mod_jk any folders off of the default port 80 server have to co-exist as
a webapp under tomcat(as far as I know). 

Can anyone help me out on this? 

Thanks!

T-

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: mod_jk and virtual folders?

Posted by David Rees <dr...@greenhydrant.com>.
On Wed, February 4, 2004 1at 2:02 pm, Tim Diez wrote:
>
> I'd like to use apache and mod_jk to dynamically re-route all subfolders
> of my httpd web server to a single Tomcat webapp.
>
> http://www.myserver.com/
> http://www.myserver.com:8080/mywebapp
>
> The tricky part for me has been setting this up to be dynamically
> routed.  What I'd like to do is have myserver.com/<anyfolder> route to
> myserver:8080/mywebapp, so I don't have to create a virtual host for
> every potential subfolder on myserver.com:80/
>
> So, I need http://www.myserver.com/*/hello.do?param=nada to map to
> http://www.myserver.com:8080/mywebapp/hello.do?param=nada
>
> I need the url to always keep the original host/folder.  I tried
> mod_rewrite, but it changes the URL after the redirection.  If I use
> mod_jk any folders off of the default port 80 server have to co-exist as
> a webapp under tomcat(as far as I know).

You'll have to use mod_rewrite for this, and you'll have to make sure that
you're using internal redirects (or forwards) instead of exernal
redirects.  This will require that you have mod_proxy installed as well.

So something like this may work:

RewriteEngine on
RewriteRule ^/(.*)/(.*)$  http://www.myserver.com:8080/$2 [P,L]

What rewrite config did you try before?

-Dave

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org