HI i m trying to create virtual hosts for my PHP sites.I edited httpd-vhosts.conf with the following code

<VirtualHost *:80>  
 DocumentRoot C:/xampp/htdocs/logo
 ServerName localhost
 </VirtualHost>

<VirtualHost *:80>  
 DocumentRoot C:/xampp/htdocs/new
 ServerName local
 </VirtualHost>

and host file with

127.0.0.1       local
127.0.0.1       localhost

Now the logo project is accessible but the new is not.

link|improve this question
If you could post your entire virtual host configs, then we might be able to help you more, but now I think there's not enough information. – Imi Borbas Mar 24 '11 at 14:06
Can you post the entire <VirtualHost> section for each virtual host? – Justin Dearing Mar 24 '11 at 14:07
He did, it was just lost in the formatting ;) – ZeissS Mar 24 '11 at 14:08
did you restart the apache server? – sharpner Mar 24 '11 at 14:08
<VirtualHost *:80> DocumentRoot C:/xampp/htdocs/logosnap ServerName localhost </VirtualHost> <VirtualHost *:80> DocumentRoot C:/xampp/htdocs/new ServerName local </VirtualHost> – Anonymous Mar 24 '11 at 14:09
show 1 more comment
feedback

migrated from stackoverflow.com Mar 24 '11 at 22:49

This question came from our site for professional and enthusiast programmers.

3 Answers

When you write <VirtualHost *:80> you are telling Apache to listen in any ip address regardless the ServerName.

What you have to do it's put the ServerName instead of *, like this:

<VirtualHost localhost:80>  
 DocumentRoot C:/xampp/htdocs/logo
 ServerName localhost
 </VirtualHost>

<VirtualHost local:80>  
 DocumentRoot C:/xampp/htdocs/new
 ServerName local
 </VirtualHost>

This is because the ServerName is in the HTTP header.

link|improve this answer
feedback
NameVirtualHost localhost
<VirtualHost localhost>  
 DocumentRoot C:/xampp/htdocs/logo
 ServerName localhost
</VirtualHost>

NameVirtualHost local
<VirtualHost local>  
 DocumentRoot C:/xampp/htdocs/new
 ServerName local
</VirtualHost>

I would try this.

link|improve this answer
feedback

i think you cannot use local as virtualname, try something like local.de or dev.de I don't know, but at least with one point in it.

I believe the only exception to that is localhost.

also don't forgot to restart the apache server when you change the config file

EDIT:

<VirtualHost *:80>  
 DocumentRoot C:/xampp/htdocs/logo
 ServerName localhost
 ServerAlias localhost
 </VirtualHost>

<VirtualHost *:80>  
 DocumentRoot C:/xampp/htdocs/new
 ServerName dev.com
 ServerAlias dev.com
 </VirtualHost>

try this, this is how I use it

link|improve this answer
dev.de also opens logosnap – Anonymous Mar 24 '11 at 14:12
Can you try your public IP instead of the localhost ip? Maybe Apache has some special handling for the '127.0.0.1' – ZeissS Mar 24 '11 at 14:32
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.