7

I want to do the following with Tomcat 5.5:

*.mydomain.com should go to my webapp, located at the virtual host mydomain.com. So I have a virtual host mydomain.com, and I want all *.mydomain.com also go there.

Now, if I do this, it doesn't pick up the virtual host, and just goes to the default one (which is not set to mydomain.com).

How to fix this? I basically would like to allow wildcards in the host alias, or in the virtual host name itself.

(The DNS settings are alright by the way)

Marten Sytema
  • 173
  • 1
  • 7

1 Answers1

4

Have you tried adding an alias to your Host directive in the config?

<Host name="www.mycompany.com" ...> ... <Alias>*.mydomain.com</Alias> ... </Host>

This usually fixes it for me

lynxman
  • 9,397
  • 3
  • 25
  • 28
  • I used the host-manager, and when I look in the server.xml there are no hosts defined. Which config file does the host-manager webapp write to? But according to you wildcards should be possible? – Marten Sytema Jan 22 '11 at 12:52
  • I normally don't use the host-manager and rather write directly to the configuration files, reading about it though makes me think that the alias parameter in the manager will do the same as I was explaining just before, try it out and see how it works for you. – lynxman Jan 22 '11 at 16:27
  • @MartenSytema there should be at least one Host. The default one is called localhost. If you only have "localhost" then your virtual hosting may be happening in a different component, such as an Apache HTTP server before being proxied to Tomcat – Alastair McCormack Oct 07 '12 at 09:26
  • 3
    -1 I tried using a wildcard in the `` element and tomcat didn't route requests as expected. Furthermore, [the tomcat configuration docs for ``](http://tomcat.apache.org/tomcat-7.0-doc/config/host.html#Host_Name_Aliases) mention nothing at all about wildcard support. – Asaph Jun 01 '14 at 21:17