2016-06-12 13 views
0

Ich habe 3 vhosts auf xampp auf meinem lokalen Windows-Rechner eingerichtet. (siehe Konfiguration unten)Apache standardmäßig auf einen virtuellen Host anstelle von Root-Ordner der anderen vhosts

Immer, wenn ich meinen Browser auf stage.local oder host.local leite, werde ich zu dev.local weitergeleitet, das ist der vhost, den ich zuerst eingerichtet habe, sollte aber nicht der Standard-vhost sein.

Wenn ich jedoch zu host.local/index.php gehe, wird die korrekte Datei angezeigt, irgendwie ist es nur das Stammverzeichnis, das durcheinander ist. Ich bin mir nicht sicher, wie das möglich ist oder wie man das beheben kann.

Die Konfiguration scheint richtig, hier ist die vollständige Datei:

# 
# Use name-based virtual hosting. 
# 
NameVirtualHost * 
# 
# VirtualHost example: 
# Almost any Apache directive may go into a VirtualHost container. 
# The first VirtualHost section is used for all requests that do not 
# match a ##ServerName or ##ServerAlias in any <VirtualHost> block. 
# 


<VirtualHost *> 
    ServerAdmin [email protected] 
    DocumentRoot "C:/xampp/htdocs/host.local/" 
    ServerName host.local 
</VirtualHost> 

<VirtualHost *> 
    ServerAdmin [email protected] 
    DocumentRoot "C:/xampp/htdocs/stage.local/" 
    ServerName stage.local 
    ErrorLog "logs/stage.local-error.log" 
    CustomLog "logs/stage.local-access.log" common 
</VirtualHost> 

<VirtualHost *> 
    ServerAdmin [email protected] 
    DocumentRoot "C:/xampp/htdocs/dev.local/" 
    ServerName dev.local 
    ErrorLog "logs/dev.local-error.log" 
    CustomLog "logs/dev.local-access.log" common 
</VirtualHost> 

Und httpd -S sagt dies:

*:*     is a NameVirtualHost 
    default server host.local (C:/xampp/apache/conf/extra/httpd-vhosts.conf:29) 
    port * namevhost host.local (C:/xampp/apache/conf/extra/httpd-vhosts.conf:29) 
    port * namevhost stage.local (C:/xampp/apache/conf/extra/httpd-vhosts.conf:35) 
    port * namevhost dev.local (C:/xampp/apache/conf/extra/httpd-vhosts.conf:43) 

(einige ssl Sachen nach)

und meine hosts-Datei hat die folgenden Einträge:

127.0.0.1 localhost 
127.0.0.1 host.local 
127.0.0.1 stage.local 
127.0.0.1 dev.local 

Antwort

0

Für mich funktioniert es. Sie müssen einen Port definieren für zB: -

# 
# Use name-based virtual hosting. 
# 
NameVirtualHost *:80 
# 
# VirtualHost example: 
# Almost any Apache directive may go into a VirtualHost container. 
# The first VirtualHost section is used for all requests that do not 
# match a ##ServerName or ##ServerAlias in any <VirtualHost> block. 
# 


<VirtualHost *:80> 
    ServerAdmin [email protected] 
    DocumentRoot "C:/xampp/htdocs/host.local/" 
    ServerName host.local 
</VirtualHost> 

<VirtualHost *:80> 
    ServerAdmin [email protected] 
    DocumentRoot "C:/xampp/htdocs/stage.local/" 
    ServerName stage.local 
    ErrorLog "logs/stage.local-error.log" 
    CustomLog "logs/stage.local-access.log" common 
</VirtualHost> 

<VirtualHost *:80> 
    ServerAdmin [email protected] 
    DocumentRoot "C:/xampp/htdocs/dev.local/" 
    ServerName dev.local 
    ErrorLog "logs/dev.local-error.log" 
    CustomLog "logs/dev.local-access.log" common 
</VirtualHost> 
Verwandte Themen