2

Background:

I have a host configured in my Tomcat's server.xml as:

<Host name="mydomain.com" 
    appBase="webapps/myapp" 
    unpackWARs="true" 
    autoDeploy="true"
    xmlValidation="false" 
    xmlNamespaceAware="false">
        <Context path="" docBase="."/>
    </Host>

Problem:

When I type http://mydomain.com into my browser, it works well. But when I type http://www.mydomain.com it shows a blank page.

Workaround I tried:

I tried to create another host as:

<Host name="www.mydomain.com" 
        appBase="webapps/myapp" 
        unpackWARs="true" 
        autoDeploy="true"
        xmlValidation="false" 
        xmlNamespaceAware="false">
            <Context path="" docBase="."/>
        </Host>

Result:

It seemed to work okay ( when I typed http://www.mydomain.com, it would show me regular site ). But later I discovered this way Tomcat creates two instances of the same application; that invalidates this approach.

Please let me know if in your opinion there is a better workaround.

Many Thanks!

P.S.

This is my first question at serverfault.com, I am not sure if this question has been asked before ( at least I couldn't find any ). Link to any such related question would also be appreciated.

1 Answer 1

3

You need a virtual host name alias.

<Host name="www.mydomain.com" ...>
  ...
  <Alias>mydomain.com</Alias>
  ...
</Host>
1
  • Thanks a lot XCondE, had no idea that it would be so simple :)
    – craftsman
    Jul 24, 2010 at 1:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .