I just realized that nothing else on WAMP is accessible unless it's under the virtual host alias. For example: if I name my vHost 'mysite.dev', I can only access mysite.dev and everything else gives a 403 forbidden error. If I add a vHost called anothersite.dev in addition to mysite.dev, only those sites can be accessed. The only thing under localhost that I can access is PHPMyAdmin. I have uncommented the line that includes vHosts.conf in the Apache httpd.conf file. This problem does not happen until I modify the vHosts.conf file. Here is the config for the other files:
vHosts.conf:
<VirtualHost *:80> ServerAdmin webmaster@dummy-host.example.com DocumentRoot "c:/Apache24/docs/dummy-host.example.com" ServerName dummy-host.example.com ServerAlias www.dummy-host.example.com ErrorLog "logs/dummy-host.example.com-error.log" CustomLog "logs/dummy-host.example.com-access.log" common </VirtualHost> <VirtualHost *:80> ServerAdmin webmaster@dummy-host2.example.com DocumentRoot "c:/Apache24/docs/dummy-host2.example.com" ServerName dummy-host2.example.com ErrorLog "logs/dummy-host2.example.com-error.log" CustomLog "logs/dummy-host2.example.com-access.log" common </VirtualHost> <VirtualHost *:80> ServerAdmin webmaster@dummy-host2.example.com DocumentRoot "W:/wamp/www/mysite" ServerName mysite.dev ErrorLog "logs/dummy-host2.example.com-error.log" CustomLog "logs/dummy-host2.example.com-access.log" common </VirtualHost>
Windows hosts file:
127.0.0.1 localhost 127.0.0.1 mysite.dev
Ok first, the first 2 VHOST definitions in the httpd-vhost.conf
file (vhost and vhost2) are examples, supplied by Apache, to help you get started and of course point to folders that do not exist so and should be removed.
Second When you create a Virtual Host you should include the access privilages for the VHOST in a <Directory....>
group.
Third, you should always create a VHOST for localhost as once VHOSTs are created Apache ignores the localhost definition in httpd.conf
So your httpd-vhost.conf
file should look like this
# Should be the first VHOST definition so that it is the default virtual host # Also access rights should remain restricted to the local PC and the local network # So that any random ip address attack will recieve an error code and not gain access <VirtualHost *:80> ServerAdmin webmaster@homemail.net DocumentRoot "W:/wamp/www" ServerName localhost <Directory "W:/wamp/www"> AllowOverride All Require local </Directory> </VirtualHost> <VirtualHost *:80> DocumentRoot "W:/wamp/www/mysite" ServerName mysite.dev ErrorLog "logs/mysite.dev-error.log" CustomLog "logs/mysite.dev-access.log" common <Directory "W:/wamp/www/mysite"> Options Indexes FollowSymLinks AllowOverride All Require local </Directory> </VirtualHost>
Once you have done this, you now need to edit your c:\windows\system32\drivers\etc\hosts
file to look like this. You need to have admin privilages to edit this file, also some anti virus suites also protect this file, so you may need to stop that protection temporarily in order to amend this file.
127.0.0.1 localhost 127.0.0.1 mysite.dev ::1 localhost ::1 mysite.dev
Then restart the dnscache to pick up these changes, from a command line also started with admin privilages.
net stop dnscache net start dnscache
This post may help you understand more about Virtual Hosts