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.

link|improve this question
feedback

1 Answer

up vote 1 down vote accepted

You need a virtual host name alias.

<Host name="www.mydomain.com" ...>
  ...
  <Alias>mydomain.com</Alias>
  ...
</Host>
link|improve this answer
Thanks a lot XCondE, had no idea that it would be so simple :) – craftsman Jul 24 '10 at 1:37
feedback

Your Answer

 
or
required, but never shown

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