1

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.

6
  • 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, 2011 at 14:06
  • Can you post the entire <VirtualHost> section for each virtual host? Mar 24, 2011 at 14:07
  • He did, it was just lost in the formatting ;)
    – ZeissS
    Mar 24, 2011 at 14:08
  • did you restart the apache server?
    – sharpner
    Mar 24, 2011 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, 2011 at 14:09

3 Answers 3

2

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.

0
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.

0

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

2
  • dev.de also opens logosnap
    – Anonymous
    Mar 24, 2011 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, 2011 at 14:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .