I am on Windows 8 and just now installed Wamp 2.5 (Apache 2.4.9) at C:/wamp
to test my code locally. I have my source code repository at D:/workpace/project1
which I manage using GIT (GIT is one of the reasons I don't want to disturb its location).
After Installing Wamp, I just went on to enable virtual hosts by uncommenting the following line in httpd.conf
.
#Include conf/extra/httpd-vhosts.conf
Then I headed to conf/extra/httpd-vhosts.conf
created its backup and created the virtual host.
<VirtualHost *:80>
ServerAdmin admin@example.com
DocumentRoot "D:/workspace/project1/"
ServerName project1
ServerAlias p1
ErrorLog "logs/project1(local)-error.log"
CustomLog "logs/project1(local)-access.log" common
<Directory "D:/workspace/project1/">
Require all granted
</Directory>
</VirtualHost>
Also edited the hosts file and added the necessary lines.
127.0.0.1 project1
127.0.0.1 p1
The problem is that I get 403 Forbidden
error not just when I access project1/
and p1/
, but also when I access localhost/
.
When I disable httpd-vhosts.conf in httpd.conf by commenting out,
Include conf/extra/httpd-vhosts.conf
I am able to access localhost/
but as expected, project1/
and p1/
too resolve to localhost/
.
Surprisingly, when I re-enable httpd-vhosts.conf
in httpd.conf
and restore the backup of original(unchanged) httpd-vhosts.conf
, I still get 403 (Forbidden)
even on localhost/
. But again when I disable httpd-vhosts.conf
, localhost/
comes to normal.
It is furthermore surprising to note that If I change DocumentRoot
to a dummy folder within c:/wamp/www
, the story is the same. So this is not just happening when DocumentRoot
is outside c:/wamp/www
.
I feel that I have something extra to enable because there is no chance I have messed up anything as this is a fresh installation and I have made no changes except the ones above.
What may be the reason Apache is not getting along with virtual hosts?