Help - Search - Members - Calendar
Full Version: Problem setting up virtual hosts
The Planet Forums > System Administration > Web Hosting
Harvey
Hi there,

I'm trying to set up ip-based virtual hosting on my box, and am having a strange issue.

I have two sites, site1.com and site2.com, each with its own IP 123.123.123.123 and 456.456.456.456 (as examples).

This is what my httpd.conf looks like:

Listen 80

<VirtualHost 123.123.123.123:80>
DocumentRoot /home/.sites/_default/web
ServerName www.site1.com
</VirtualHost>

<VirtualHost 456.456.456.456>
DocumentRoot /home/.sites/site2/web
ServerName www.site2.com
</VirtualHost>

# END

It all seems pretty basic! But this is what happens:

http://site1.com --> resolves properly to site 1
http://www.site1.com --> resolves perperly to site 1
http://www.site2.com --> resolves properly to site 2
http://site2.com --> resolves erroneously to site 1

Do I need to make changes to other files to make this work properly? Or am I missing somethign in my conf file?

DNS info:
My domain at my registrar is using The Planet's DNS servers.
The Planet has set its DNS to point site1.com to 123.123.123.123 and site2.com to 456.456.456.456.

Thanks a lot for the help!

Matt.
24x7servermanagement
Hi

If the DNS zones are correctly configured which i believe it is. Add a ServerAlias parameter in the Virtual host entry for site2.com. for ex.

<VirtualHost 456.456.456.456>
DocumentRoot /home/.sites/site2/web
ServerName www.site2.com
ServerAlias site2.com
</VirtualHost>

Hope this should work.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.