Search code examples
apachexamppphp-5.3vhosts

Multiples vHosts with XAMPP 1.7.3


I'm trying to configure multiple vhosts on a machine on my network , however, no matter what I use to access servername , the apacche always directs to the first host.

Here it's my vHosts file

<VirtualHost eurekahom:7777>
    DocumentRoot "d:\vhosts\eurekahom\controller/"
    ServerName eurekahom

 #   RewriteEngine On
 #   RewriteOptions Inherit

    <Directory />
        AllowOverride All    
    </Directory> 

    php_value include_path ".;d:\vhosts\eurekahom\controller\includes/"
</VirtualHost>


<VirtualHost eurekades:7777>
    DocumentRoot "d:\vhosts\eurekades\controller/"
    ServerName eurekades

    <Directory />
        AllowOverride All    
    </Directory>

    php_value include_path ".;d:\vhosts\eurekades\controller\includes/"
</VirtualHost>

<VirtualHost mauricio:7777>
    DocumentRoot "d:\htdocs\mauricio" 
    #\controller/"
    ServerName mauricio

 #   RewriteEngine On
 #   RewriteOptions Inherit

    <Directory />
        AllowOverride All    
    </Directory> 

    php_value include_path ".;d:\htdocs\mauricio"
</VirtualHost>

Did anyone know what's happend?


Solution

  • I believe for virtual hosts there are IP-based matching and server name matching. So whatever you type here: <VirtualHost ________:7777> should be an IP address. Since you don't want to match by IP, you can just leave a *:7777.

    So yes, all your statements will start with <VirtualHost *:7777>. When a request comes for that 7777 port, Apache will then try to match by server name, and then the ServerName parameter will be considered.

    There might be more issues with the <Directory> statement too, but I believe that is not what was causing Apache to always use the first VirtualHost all the time.

    The following link is very useful, as it helped me when I had a very similar problem: https://wiki.apache.org/httpd/CommonMisconfigurations