Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 3 down vote accepted

You need a virtual host name alias.

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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