Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Virtual Host does not work please help

Status
Not open for further replies.

yoramdar

IS-IT--Management
Jan 8, 2004
15
US

Hi,
Recently I have purchased a new Domain name, which I would like to dedicate to directory in my main website. I thought the best idea was to define a virtual host in the apache (I use apache 2).

To my surprise, when I defined one virtual host (the main website with the first domain name, and one virtual website with the new Domain Name) I couldn't access it. When I defined two virtual hosts (one for the main website and one for the new one), whichever domain name I had first declared was the only one I could access with the both domain names.

Could anyone help me with this issue?


 
Please post your vhost configurations for us to look at.
 
Check your virtual host section looks similiar to this and make sure that the NameVirtualHost points to your IP:
NameVirtualHost 10.1.1.1

*The first virtual host entry should be your default domain:

<VirtualHost 10.1.1.1>
ServerName ServerAlias defaultdomain.com
DocumentRoot /home/domainone/www
</VirtualHost>

<VirtualHost 10.1.1.1>
ServerName ServerAlias newdomain.com
DocumentRoot /home/newdomain/www
</VirtualHost>



************************
 
Hi guys,
Thanks for answering quickly.
The httpd.conf definitions are as flow:
The first two are the default hosts and the others are the new host.
I have been told that I need to define two VHOST for every virtual host one with one without.
I have one IP address, which is being pointed by both domain names. And it seems that the DNS definitions are O.K.

<VirtualHost *>
ServerName DocumentRoot /home/</VirtualHost>

<VirtualHost *>
ServerName embassyofisrael.org
DocumentRoot /home/</VirtualHost>
<VirtualHost *>
ServerName DocumentRoot /home/</VirtualHost>

<VirtualHost *>
ServerName israel4kids.org
DocumentRoot /home/</VirtualHost>
 
You do NOT need two vhosts for each domain. You would use ServerAlias instead :

ServerName mydomain.com
ServerAlias
You will also need to check two more things. This directive should be uncommented. It is usually just above the sample vhost container:

NameVirtualHost * (If you don't see it, add it)

You will also nee to make sure that UseCanonicalName is set to Off
 
Thanks,

It does work.
I used ServerAlias and NameVirtualHost *

I also commented ServerName

Thank you very much
 
You shouldn't coment out ServerName. When you are using name based addressing on one ip, that is how apache finds the correct server. What I was saying is that you should use both ServerName and ServerAlias for one domain instead of creating two vhosts.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top