Subdomain unter Apache einrichten - Probleme
-
Hallo,
ich möchte eine Subdomain einrichten, welche unter Apache erreichbar sein soll. Momentan ist der Apache wohl auf Wildcard-Subdomains konfiguriert, weswegen jede Subdomain auf Port 80 weiterleitet und mir die normale Homepage anzeigt. Ich möchte jedoch für eine bestimmte Subdomain einen eigenen
DocumentRootanlegen.Die Konfigurationsdatei sieht bis jetzt so aus:
# Nachfolgende Angaben sind außerhalb von <VirtualHost> etc... ServerName http://www.example.com ... DocumentRoot "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs" <VirtualHost www.example.com:443> SSLEngine On SSLCertificateFile conf/ssl/example.cert SSLCertificateKeyFile conf/ssl/example.key DocumentRoot "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs" </VirtualHost> <VirtualHost meinesubdomain.example.com:80> ServerName meinesubdomain.localhost DocumentRoot "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/subdomainverzeichnis" </VirtualHost>Beim Aufruf von
meinesubdomain.example.comwird korrekterweise das angegebene Subdomain-Verzeichnis alsDocumentRootangesurft. Anfragen auf meine normale Domain, ohne Subdomainangabe führen jedoch ebenfalls zum Verzeichnis der Subdomain. Anfragen über HTTPS führen dann korrekterweise wieder auf die normale Webseite.Was ist da falsch?
-
Keiner 'ne Ahnung?
-
kanns grad nicht testen, aber ich glaub du musst für www.example.com nen eigenen vhost aufsetzen.
-
Okay, vielen Dank soweit schon mal. Ich werde es morgen ausprobieren und dann berichten...
-
Hallo,
pass auf, wenn du vHosts anlegst: Der erste geparste vHost ist der Default. Wenn du also eine eigene Config pro vHost hast (wie z.B. unter Debian mit sites-available/enabled), nenn sie am besten aaa-name.
Viele Grüße
Christian
-
Okay, danke... die Konfiguration sieht jetzt folgendermaßen aus:
<VirtualHost www.example.com:80> ServerName www.example.com DocumentRoot "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs" </VirtualHost> <VirtualHost conf.example.com:80> ServerName conf.example.com DocumentRoot "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/subdomainverzeichnis" </VirtualHost> <VirtualHost www.example.com:443> SSLEngine On SSLCertificateFile conf/ssl/example.cert SSLCertificateKeyFile conf/ssl/example.key DocumentRoot "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs" </VirtualHost>Jedoch bringt der Apache beim Start folgenden Hinweis:
Apache Webserver schrieb:
VirtualHost www.example.com:80 overlaps with VirtualHost conf.example.com:80, the first has precedence, perhaps you need a NameVirtualHost directive.
Gut okay, dadurch, dass der erste VirtualHost Vorrang hat, wird auch korrekterweise beim Aufruf von www.example.com die Webseite angezeigt, jedoch auch bei conf.example.com. Nie wird auf das Subdomainverzeichnis geleitet.
Ich habe es auch schon mit "localhost" bzw. "conf.localhost" als Angabe versucht, das macht es alles aber auch nicht besser. Und die Direktive
NameVirtualHostexistiert nicht (neueste Apache-Version.)Hat noch jemand einen Tipp?
-
perhaps you need a NameVirtualHost directive.
-
Argh, ich hätte vorher besser schauen sollen,
<NameVirtualHost>gibt es nicht, das heißtNameVirtualHostals Argument... jetzt funktioniert es, vielen Dank.