I have installed Wamp so I can run a few simple dynamic sites that I built. I want to be able to have three or four and learn how to do things at local level and then upload the improved files to the live site without having to rewrite sections due to different location/paths etc.
To get WampServer index page to show I go to http-vhosts.conf and add
<VirtualHost 127.0.0.1>
ServerName localhost
DocumentRoot "E:/wamp/www"
</VirtualHost>
I understand that I put my site directory labelled mysite.local into the E:wamp/www so the path becomes E:wamp/www/mysite.local. I then go to http-vhosts.conf and add
<VirtualHost *:80>
ServerName mysite.local
DocumentRoot "E:/wamp/www/mysite.local"
</VirtualHost>
my host file has
127.0.0.1 localhost
127.0.0.1 mysite.local
and my httfp.conf has
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
So my problem with all this done I get my WampServer index showing fine when I type localhost in the url, and mysite.local appears on that index page under "Your Projects" which is all good, but when I click on the mysite.local link from WampServer, the url changes to localhost/mysite.local not mysite.local, and then when I click a page link from localhost/mysite.local I get localhost/mysite.local/linkedpage as the url and a 404 error.
mysite.local as the url also brings up the WampServer index page
If I comment out ServerName localhost from http-vhosts.conf and restart apache. I get what I'm after when I try mysite.local as the url - mysite works and all the dynamic links work. but the WampServer index is then a 404 error.
All I want to be able to do is log in to WampServer and visit various sites from "Your Projects" list.
Please help a numpty
hosts
file and httpd.conf
look OK.
Some things to try ...
<VirtualHost *:80>
for both virtual hosts.
Make sure DocumentRoot
strings have a terminal /
.
For the root virtual host, ServerName localhost:80
.
To browse via the virtual hosts, always omit localhost/
from the url. The "Your Projects" links include localhost/
and access projects as paths from the root, not as independent sites, each with its own root (which is what virtual hosts gives you).
(WAMP 2) When everything else is fixed ... to bring the "Your Virtual Hosts" section of the root "index.php" page alive , follow these instructions. I just did this and have no regrets. Now I can click links to access my sites served as virtual hosts - yay! Exactly what I always wanted of the "Your Projects" links but didn't get.
BTW, the <VirtualHost>...</VirtualHost>
directives are the things that tie each host name to a particular path in the server's file system, so subdirectories in "E:/wamp/www/" don't need the ".local" suffix. After removing ".local" from the dirs themselves, make corresponding changes to the DocumentRoot
entries , eg DocumentRoot "E:/wamp/www/mysite/"
. But be sure to leave ".local" in the "ServerName" entries, eg. ServerName mysite.local
, to match the entries in your "hosts" file.