Subdomains leiten mich immer wieder auf die Hauptwebsite weiter

Subdomains leiten mich immer wieder auf die Hauptwebsite weiter

Ich habe gerade meine Version der LAMP-Umgebung aktualisiert. Ansonsten funktioniert alles einwandfrei, aber mit Subdomains habe ich ein Problem.

Ich habe eine Hauptwebsite abc.biz und 5 bis 6 Subdomains dazu, wie aaa.abc.biz, site.abc.com. Jedes Mal, wenn ich eine Subdomain besuche, werde ich auf die Hauptseite umgeleitet. Bitte helfen Sie.

Meine vollständige Konfiguration ist wie folgt:

  • Centos-6.6
  • php 5.4.29
  • MySQL 5.1.57
  • Apache 2.4.12

Ich habe mir auch einen Beitrag zum gleichen Problem angesehen, aber auch das hat nicht geholfen. Meine aktuelle httpd-vhosts.conf ist wie folgt

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "/mnt/docroot/abc"
    ServerName abc.biz
    ServerAlias *.abc.biz
    ErrorLog "logs/abc.biz-error_log"
    CustomLog "logs/abc.biz-access_log" common
<Directory />
    Require all granted
</Directory>
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "/mnt/docroot/aaa"
    ServerName aaa.abc.biz
<Directory />
    Require all granted
</Directory>
</VirtualHost>

Antwort1

Ich glaube, der Übeltäter ist die Tatsache, dass Sie in Ihrem ersten <VirtualHost>ein haben ServerAlias *.abc.biz. Sieht so aus, als ob dieses auch alle Subdomänen abdeckt.

Hier ist ein Ausschnitt aus meiner Apache-Konfiguration, und es funktioniert bei mir. Das mache ich für Subdomains, und ich habe viele davon:

<VirtualHost *:80>
        ServerName              example.com
        ServerAlias             www.example.com
        DocumentRoot            /usr/www/example.com/http/
        ScriptAlias  /cgi-bin/  /usr/www/example.com/http/cgi-bin/

        ErrorLog                /var/log/www/example.com/error.log
        CustomLog               /var/log/www/example.com/access.log combined
        <Directory />
                Options +Indexes +FollowSymlinks
        </Directory>
</VirtualHost>

<VirtualHost *:80>
        ServerName              somesubdomain.example.com
        ServerAlias             www.somesubdomain.example.com
        DocumentRoot            /usr/www/somesubdomain.example.com/http/

        # Shared log file with main domain
        ErrorLog                /var/log/www/example.com/error.log
        CustomLog               /var/log/www/example.com/access.log combined
</VirtualHost>

verwandte Informationen