Wamp Server: Multiple Virtual Hosts are not working on Windows

17,220

Solution 1

I'm guessing you're missing the NameVirtualHost 127.0.0.1:80 line somewhere :)

Solution 2

I did some thing like this 1- for the local host its :

NameVirtualHost localhost:80
<VirtualHost localhost:80>
ServerName localhost
ServerAlias localhost
DocumentRoot D:/wamp/www
ErrorLog "D:/wamp/www/error.log"
CustomLog D:/wamp/www/access.log common
<Directory "D:/wamp/www">
    Options -Indexes FollowSymLinks MultiViews
    AllowOverride All
    <IfModule mod_access.c>
    Order allow,deny
    Allow from all
    </IfModule>
</Directory>
</VirtualHost>

2 - and for any other local domain

NameVirtualHost zf.local:80
<VirtualHost zf.local:80>
ServerName zf.local
ServerAlias zf.local 
DocumentRoot D:/Workspace/Zend/documentation
ErrorLog "D:/Workspace/Zend/documentation/error.log"
CustomLog D:/Workspace/Zend/documentation/access.log common
<Directory "D:/Workspace/Zend/documentation">
    Options -Indexes FollowSymLinks MultiViews
    AllowOverride All
    <IfModule mod_access.c>
    Order allow,deny
    Allow from all
    </IfModule>
</Directory>
</VirtualHost>

Solution 3

You don't have to write virtual host info into httpd.conf. Just uncomment line on which you load conf/extra/httpd-vhosts.conf, then go to this file and put your info there. Should work.

Example of my httpd-vhosts.conf:

NameVirtualHost *:80

<VirtualHost 127.0.0.1>
    DocumentRoot "C:/wamp/www"
    ServerName dev
</VirtualHost>

Solution 4

You need to include something similar to following line

NameVirtualHost *

Also, it seems you are using https connection to the server which doesn't play well with virtual hosts because of the SSL protocol limitation. The Host header in the http request is encrypted and by the time apache decrypts it, it has already passed on the request to one of the virtual host.

Share:
17,220
Awan
Author by

Awan

Upvoter

Updated on June 27, 2022

Comments

  • Awan
    Awan almost 2 years

    I have two virtual hosts on windows(for example: test1.dev and test2.dev). But it always load content of test1.dev for both virtual hosts.

    Following are my files:

    hosts:

    127.0.0.1    localhost
    127.0.0.1    test1.dev
    127.0.0.1    test2.dev
    

    httpd.conf:

    <IfModule ssl_module>
    SSLRandomSeed startup builtin
    SSLRandomSeed connect builtin
    </IfModule>
    
    Include "c:/wamp/alias/*"
    
    <VirtualHost 127.0.0.1>
        ServerName test1.dev
        DocumentRoot "C:\wamp\www\test1\public"
    </VirtualHost>
    
    <VirtualHost 127.0.0.1>
        ServerName test2.dev
        DocumentRoot "C:\wamp\www\test2\public"
    </VirtualHost>
    

    Can someone recognize the problem ?