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)


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

  • 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 7 '12 at 9:26
  • 3
    -1 I tried using a wildcard in the <Alias> element and tomcat didn't route requests as expected. Furthermore, the tomcat configuration docs for <Alias> mention nothing at all about wildcard support. – Asaph Jun 1 '14 at 21:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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