views:

168

answers:

1

Hello all,

HELP! I just setup a virtual host for two sites that have a lot of traffic and I think I just messed something up! Here is the end of my httpd.conf:

NameVirtualHost *
<VirtualHost *>
ServerName www.mydomain.com
DocumentRoot /var/www/html
</VirtualHost>

<VirtualHost *>
ServerName www.mydomain2.com
DocumentRoot /var/www/downloadr
</VirtualHost>

<VirtualHost *>
ServerName mydomain2.com
DocumentRoot /var/www/downloadr
</VirtualHost>

I added the last virtual host to solve the problem of mydomain2.com going to wwww.mydomain.com. HOWEVER, what has happened now is that www.mydomain2.com goes to www.mydomain.com.

Please help!!!

Thanks all

UPDATE

STUPIDITY beyond words - managed to copy one site to two directories and hence the 2 domains pointing to the same place!! OMG this will not happen again. Double check and recheck and recheck and recheck and recheck and recheck........

Btw, why would someone neg rep me for this?

+1  A: 

Instead of adding the third virtual host, add

ServerAlias mydomain2.com

to the second one. So your entire configuration would be basically this:

NameVirtualHost *
<VirtualHost *>
    ServerName www.mydomain.com
    DocumentRoot /var/www/html
</VirtualHost>

<VirtualHost *>
    ServerName www.mydomain2.com
    ServerAlias mydomain2.com
    DocumentRoot /var/www/downloadr
</VirtualHost>

If you want requests for mydomain.com to actually be redirected to www.mydomain.com, so that the user sees the URL change in his/her browser, that can be done with mod_rewrite (but that's the subject of another question, search for it if you like)

David Zaslavsky
That looks familiar... ;-)
Sean Bright
I have done this too. Did not know it was supposed to be like that. Thank you.
Abs