phpapachewampvirtualhostvirtual-hosts

Virtual Hosts - all redirect to the WAMP localhost 'home' page


I've setup the latest version of WAMP on my Windows 8 PC - I cannot seem to get multiple virtual hosts to work, every local URL I load will show the WAMP homepage.

Can anyone explain what I am doing wrong?

// My hosts file
127.0.0.1   localhost   
127.0.0.1   client1.localhost
127.0.0.1   client2.localhost

I have two folders in my WAMP directory, 'client1' and 'client2' obviously each folder will relate the the client1 & client2 in the host file above.

// My virtual hosts file
<VirtualHost *:80>
  ServerName localhost
  DocumentRoot "C:\wamp\www"
</VirtualHost>

<VirtualHost *:80>
  ServerName client1.localhost
  DocumentRoot "C:\wamp\www\client1"
<Directory "C:\wamp\www\client1">
  allow from all
  order allow,deny
  AllowOverride All
</Directory>
 DirectoryIndex index.html index.php
</VirtualHost>

<VirtualHost *:80>
  ServerName client2.localhost
  DocumentRoot "C:\wamp\www\client2"
<Directory "C:\wamp\www\client2">
  allow from all
  order allow,deny
  AllowOverride All
</Directory>
  DirectoryIndex index.html index.php
 </VirtualHost>

Solution

  • I followed this guide and it worked fine

    I had to change the path...

    <VirtualHost *:80>
     ServerAdmin emailaddress@domain.com
     DocumentRoot "c:\wamp\www\client1"
     ServerName client1.localhost
     ErrorLog "logs/client1.log"
     CustomLog "logs/client1-access.log" common
    </VirtualHost>
    

    In addition to this.. I find this is a good quick guide for virtual hosts with WAMP http://www.techrepublic.com/blog/smb-technologist/create-virtual-hosts-in-a-wamp-server/#