Jump to content

[SOLVED] VirtualHost with same domain name as machine.


audioduck

Recommended Posts

Hi Guys,

 

Sorry if this sounds a bit lame but I'm a newb.

 

I'm running Apache on a Red Hat machine.

 

The machine has the domain name of foo.com and I have a web site called www.foo.com. I want to run 3 sites (foo.com, bar.com, baz.com) under Apache.

 

Do I configure a VirtualHost with the domain name of foo.com so that all of the serviced domains (foo.com, bar.com, baz.com) are equal or do I leave foo.com as a "primary" domain with the same name as the machine and just configure bar.com and baz.com as VirtualHosts?

 

Why don't I understand?!

 

Cheers,

 

Matt

Panic over. Sorry about this. It was clear as day in the documentation:

 

****************************************

Main host goes away

 

If you are adding virtual hosts to an existing web server, you must also create a <VirtualHost> block for the existing host. The ServerName and DocumentRoot included in this virtual host should be the same as the global ServerName and DocumentRoot. List this virtual host first in the configuration file so that it will act as the default host.

 

For example, suppose that you are serving the domain www.domain.tld and you wish to add the virtual host www.otherdomain.tld, which points at the same IP address. Then you simply add the following to httpd.conf:

 

NameVirtualHost *:80

 

<VirtualHost *:80>

ServerName www.domain.tld

ServerAlias domain.tld *.domain.tld

DocumentRoot /www/domain

</VirtualHost>

 

<VirtualHost *:80>

ServerName www.otherdomain.tld

DocumentRoot /www/otherdomain

</VirtualHost>

 

****************************************

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.