Cant get localhost to show WampServer index and dynamic urls at same time

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.


See below for a sensible vhosts definition

#
# Use name-based virtual hosting.
#
NameVirtualHost *:80


## must be first so the the wamp menu page loads
<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "D:/wamp/www"
    ServerName localhost
    ServerAlias localhost
    <Directory  "D:/wamp/www">
        Order Deny,Allow
        Deny from all
        Allow from 127.0.0.1
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "D:/websrc/www/project1"
    ServerName project1.dev
    ServerAlias project1.dev www.project1.dev
    Options Indexes FollowSymLinks
    <Directory "D:/websrc/www/project1">
        AllowOverride All
        Order Deny,Allow
        Allow from 127.0.0.1
        Allow from 192.168.2
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "D:/websrc/www/project2"
    ServerName project2.dev
    ServerAlias project2.dev www.project2.dev
    Options Indexes FollowSymLinks
    <Directory "D:/websrc/www/project2">
        AllowOverride All
        Order Deny,Allow
        Allow from 127.0.0.1
        Allow from 192.168.2
    </Directory>
</VirtualHost>

You will have to change the directory names to fit your situation.

Also remember to add your vhosts names to your HOSTS file

c:\windows\system32\drivers\etc\hosts

> 127.0.0.1 project1.dev
> 127.0.0.1 project2.dev

Virtual hosts are best setup somewhere outside the /wamp/www folder structure, in my opinion. See above in the example I have used d:\websrc\www\project1

You run a virtual hosts using project1.dev keyed directly into the browser address field.

If you want to see your virtual hosts on the wamp home page do the following:

create a folder ?:/wamp/vhosts In that folder create files named as follows: project1.dev.conf project2.dev.conf ... etc

They do not require any content, just the correct name to match you virtual hosts names

These will then show on the wamp home page under a TITLE of Your Virtual Hosts and you can click on them to launch them.