I am trying to setup virtual wamp localhost.

Localhost
root folder: c:\wamp\www

mysite.local
root folder: c:\wamp\site2

Steps of every kind is already taken: removing # from file "httpd.conf"

#Include conf/extra/httpd-vhosts.conf
addition in httpd-vhosts.conf:

<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot "c:/wamp/www"
ServerName localhost
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common 
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "c:/wamp/site2"
ServerName mysite.local
<directory "c:/wamp/site2">
    Options Indexes FollowSymLinks
    AllowOverride all
    Order Deny,Allow
    Deny from all
    Allow from 127.0.0.1
</directory>
</VirtualHost>

addition in hosts file:

127.0.0.1 mysite.local
problem is, in either case i get to www root folder through localhost or mysite.local. ANy solution?

Wamp provides to add your own vhosts in seperate folders 'vhosts' under wamp folders, and it'll load all vhosts file you added there when startup wamp server. You don't have to add your VirtualHost in httpd.conf, it makes harder to maintain or you can lost your vhosts configuration when the wamp server has been upgraded.

Try to create your vhost file named 'mysite.local.conf' file in vhosts folder. Add the following directives in your 'mysite.local.conf'.

NameVirtualHost mysite.local:80

<VirtualHost mysite.local:80>
    ServerName mysite.local
    ServerAlias mysite.local

    DocumentRoot "c:/wamp/site2"

    <Directory "c:/wamp/site2">
    Options Indexes FollowSymLinks
        AllowOverride all
        Order Deny,Allow
        Deny from all
        Allow from 127.0.0.1
    </Directory>
</VirtualHost>

Don't forget to restart your wamp server after your changed has been saved.

Here is complete Apache documentation about VirtualHost and it's related directives.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.