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

Link to comment
Share on other sites

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>

 

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.