Page 1 of 1

Vhost taking only into account the first block <VirtualHost>

PostPosted: 11. November 2009 12:59
by lamando
Hello,

I'm using xampp for many years, and I'm using virtual hosts for all my projects (one domain per project). Everything went smooths with the past versions, but now I'm trying to install the newest 1.7.2 so I can enjoy PHP 5.3, however the vhost won't work as expected!

It seems that the very first <VirtualHost> block defines the default DocumentRoot for all the following blocks!

For example I have:

Code: Select all
<VirtualHost *:80>
    DocumentRoot "G:\xampp\htdocs"
    ServerName localhost
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "G:\Projects\project1"
    ServerName project1.localhost
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "G:\Projects\project2"
    ServerName project2
</VirtualHost>


All the domains (localhost, project1.localhost and project2) are pointing to "G:\xampp\htdocs".

Now, if I change the order:

Code: Select all
<VirtualHost *:80>
    DocumentRoot "G:\Projects\project1"
    ServerName project1.localhost
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "G:\xampp\htdocs"
    ServerName localhost
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "G:\Projects\project2"
    ServerName project2
</VirtualHost>


This time all the domains are pointing to "G:\Projects\project1", including localhost.

This is really weird since this very same configuration worked very well during the past 2 years so it must be a problem with the new version of XAMPP 1.7.2!

Both httpd-vhosts.conf and httpd.conf are exactly the same (expected the new values) as my previous installation of xampp.

There is no explanation :| I'm trying new settings for 2 days now and I would really appreciate your help!

Thank you.


--------------------
XP Pro x32 SP3 and xampp 1.7.2.

Re: Vhost taking only into account the first block <VirtualHost>

PostPosted: 11. November 2009 14:31
by Nobbie
You forgot to specify the NameVirtualHost Directive.

See http://httpd.apache.org/docs/2.0/en/vho ... based.html

Re: Vhost taking only into account the first block <VirtualHost>

PostPosted: 11. November 2009 19:56
by lamando
Nobbie wrote:You forgot to specify the NameVirtualHost Directive.

See http://httpd.apache.org/docs/2.0/en/vho ... based.html

OMG the line
Code: Select all
NameVirtualHost *:80
was commented in the httpd-vhosts.conf of the new installation and I missed that!

Thank you soooooo much!!!!! It works!!!!