You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Hunter Hillegas <li...@lastonepicked.com> on 2001/04/12 17:26:24 UTC

Serving with Virtual Hosts w/o a Context Name - ?

Here's my setup:

Tomcat 3.2.1 with Apache 1.3.19 on Red Hat 6.2.

We have about 50 IP based virtual hosts, some of which use Tomcat, others
which do not.

Is it possible to setup Tomcat to serve a virtual host the contents of a
context without the context name having to be in the URL?

I.e. www.somedomain.com goes directly to the context mywebapp instead of it
having to be www.somedomain.com/mywebapp/ ?

I thought I saw a site that did this but I wasn't sure, especially since I
have Apache in the mix and all the virtual hosts...

The FAQ-O-Matic answer is to put in a redirect. That works fine, just seems
less elegant.

Any ideas?
Hunter


Re: Serving with Virtual Hosts w/o a Context Name - ?

Posted by David Crooke <da...@convio.com>.
There are a couple of solutions; easiest is probably using mod_alias, i.e.
RedirectMatch ^/$ /mywebapp/ [R=302] in Apache. You can also put a META
http-equiv tag in an index.html file to achieve the same effect via the
browser.

If you want to hide the URL, you can use mod_rewrite to add the "mywebapp" on
the server side, but this will be more work to maintain, and it may not be so
easy to maintain the abstration in the JSP (perhaps sticking to fully relative
URL's?)

I think it may be possible to make the Tomcat context "/" - we couldn't do
that in our system (JServ based) as we also serve static content from the same
hosts.

Hunter Hillegas wrote:

> Here's my setup:
>
> Tomcat 3.2.1 with Apache 1.3.19 on Red Hat 6.2.
>
> We have about 50 IP based virtual hosts, some of which use Tomcat, others
> which do not.
>
> Is it possible to setup Tomcat to serve a virtual host the contents of a
> context without the context name having to be in the URL?
>
> I.e. www.somedomain.com goes directly to the context mywebapp instead of it
> having to be www.somedomain.com/mywebapp/ ?
>
> I thought I saw a site that did this but I wasn't sure, especially since I
> have Apache in the mix and all the virtual hosts...
>
> The FAQ-O-Matic answer is to put in a redirect. That works fine, just seems
> less elegant.
>
> Any ideas?
> Hunter

--
David Crooke, Chief Technology Officer
Convio Inc. - the online partner for nonprofits
4801 Plaza on the Lake, Suite 1500, Austin TX 78746
Tel: (512) 652 2600 - Fax: (512) 652 2699