views:

311

answers:

1

Some details

  • XAMPP 1.7.1
  • OS tested on vista and xp

Hello everyone. I have some problems with configuring my virtual hosts. Currently I have two sites.

Here is my vhost.conf file:

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot c:/xampp/htdocs/site1/trunk/
    ServerName site1.local
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot c:/xampp/htdocs/site2/trunk/
    ServerName site2.local
</VirtualHost>

And of course in my host file I have

127.0.0.1 site1.local
127.0.0.1 site2.local

I have restarted apache as well as my browser various times.

Here is my problem:

http://site1.local works. But when i go to http://site2.local, I land at site1.local.

any idea's?

+1  A: 

Try

<VirtualHost "site1.local">
    ServerAdmin spam@a1230912##ad#.nl
    DocumentRoot c:/xampp/htdocs/site1/trunk/
    ServerName site1.local
</VirtualHost>

<VirtualHost "site2.local">
    ServerAdmin spam@a1230912##ad#.nl
    DocumentRoot c:/xampp/htdocs/site2/trunk/
    ServerName site2.local
</VirtualHost>

You always get site1 because Apache default to the first.

edit

Uncomment

#NameVirtualHost *

to

NameVirtualHost *

In your httpd.conf

Mine says (/etc/httpd/conf/httpd.conf)

126 # Listen: Allows you to bind Apache to specific IP addresses and/or
127 # ports, in addition to the default. See also the <VirtualHost>
128 # directive.
129 #
130 # Change this to Listen on specific IP addresses as shown below to 
131 # prevent Apache from glomming onto all bound IP addresses (0.0.0.0)
132 #
133 Listen 127.0.0.1:80
134 NameVirtualHost 127.0.0.1

And my vhost file has

<VirtualHost "www.whatever.com">
        DocumentRoot /var/www/html/whatever/pub
        ErrorLog logs/error_log
        ServerName www.whatever.com
...
Aiden Bell
I tried with and without quotes but no results
sanders
What apache version are you using?
Aiden Bell
could you als please remove the email adresses in this post since they're not relevant.Thanks
sanders
Removed emails, done edit about NameVirtualHost. Don't worry, I don't think the spambots saw you :P
Aiden Bell
hehe ;-)Apache version:2.2.11couldn't find #NameVirtualHost *:80. added it to the bottom. Restarted apache. restarted browser. No result
sanders
Did you remove the '#' character?
Aiden Bell
Yep i did remove it.
sanders
Sorry im an idiot. See redit
Aiden Bell
You can't specify a port on the NameVirtualHost directive.
Aiden Bell
btw NameVirtualHost is in my httpd-vhost.conf that's where i uncommented it.
sanders
so what do i do now?
sanders
no /etc/httpd/conf/httpd.conf or similar (depends on distribution)
Aiden Bell
I tried it there b4 but also didn't work.
sanders
NameVirtualHost works! Thanks
sanders
Sweet! That took some doing :P Good luck!
Aiden Bell
tnx man! your'e great
sanders