Your hosts file looks good, but your virtual hosts definitions are not so good.
If you change your hosts
file you can reload the windows cache by doing this from a command window that has been launched using Runs as Administrator
or a simple reboot :-
net stop "DNS Client"
then when that completes do
net start "DNS Client"
Quotes required as there is a space in the service name!!
The DNS Client service caches domain names accessed and is pre loaded with domain names that exists in the HOSTS
file at boot time or if you restart the service as above.
When debugging a new vhost definition, remember, that if something is wrong with a definition you are attempting to access, Apache will always default to the first vhost defined in the vhost definition file. So if thats where you end up i.e. the WAMP homepage, you can assume you made a mistake defining that vhost.
This also means that if you define that first vhost definition with something like Require local
a random hack on your system should also be sent there, if that has its security set to Require local
the hack should receive a 404 error which might discourage further hack attempts.
// My virtual hosts file
<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:\wamp\www"
<Directory "C:\wamp\www">
AllowOverride All
# never want to allow access to your wamp home page area to anyone other than This PC
# plus us the Apache 2.4.x syntax and not the 2.2 syntax
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName client1.localhost
DocumentRoot "C:\wamp\www\client1"
<Directory "C:\wamp\www\client1">
AllowOverride all
# use Apache 2.4 syntax to all access to your internal network only
Require ip 192.168.0
# Or if you really want to give access to the whole internet uncomment this and comment the previous line
#Require all granted
</Directory>
DirectoryIndex index.html index.php
</VirtualHost>
<VirtualHost *:80>
ServerName client2.localhost
DocumentRoot "C:\wamp\www\client2"
<Directory "C:\wamp\www\client2">
AllowOverride all
# use Apache 2.4 syntax to all access to your internal network only
Require ip 192.168.0
# Or if you really want to give access to the whole internet uncomment this and comment the previous line
#Require all granted
</Directory>
DirectoryIndex index.html index.php
</VirtualHost>
If you don't actually want the world to be allowed access to these client sites, but you do want to be able to access the site from other PC's on your internal network then a better access mechanism would be to use Require ip 192.168.0
. Note the use of just the first 3 quartiles of your subnet ( yours may not be 192.168.0, but a lot of routers default to that. Check your subnet first )
Also if you do want the world to see these client sites then you have to Port Forward
your router as well.
Also if you didn't intend to give access to these site to the whole world, but were just following bad advice, a much more secure definition of all these sites would be to use Require local
so you can only access them from the PC running WAMP.
WAMPServer 2.4, which I assume you mean when you say you are running the latest release of WAMPServer actually changed the the way that you can include vhost definitions. Well actually it included a new way and kept the old way as well.
So to include the vhost definition you can do one of these 2 things :-
1.
Put your vhost definitions into the file \wamp\bin\apache\apache2.4.4\conf\extra\httpd-vhosts.conf and then in the
httpd.conf file uncomment this line ( its near the bottom of the conf file.
# Virtual hosts
#Include conf/extra/httpd-vhosts.conf
Remove the #
infront of the Include
line
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
2.
Place your vhost definitions into a file 'called anything you like' into the \wamp\vhost
folder.
There is a line at the bottom of the httpd.conf
file now that say IncludeOptional "d:/wamp/vhosts/*"
This will include any file in that folder and if it is a vhost definition it will apply that to the config. This is a new command to Apache 2.4 I believe so will only work on Apache 2.4.x installs.