views:

1030

answers:

4

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 ?

+5  A: 

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

WoLpH
I added (NameVirtualHost 127.0.0.1:80) in httpd.conf file and It is OK now.
Awan
+1  A: 

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>
Ondrej Slinták
where is httpd-vhosts.conf in windows os directories?
NAVEED
{wamp-dir}\bin\apache\Apache2.2.11\conf\extra\
Ondrej Slinták
Also, check this guide: http://www.dennisplucinik.com/blog/2007/08/16/setting-up-multiple-virtual-hosts-in-wamp/
Ondrej Slinták
+1  A: 

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>
tawfekov
+1  A: 

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.

Anshul