Debian Apache2中的虚拟主机重叠

Debian Apache2中的虚拟主机重叠

我有一个域名域名.com和一个子域名子域名.com

在 apache2/sites-available 中我有 2 个 vhosts 文件:领域

当我做a2ensite 子子域名会覆盖域名,因此当我查看主域名时,我会看到子域名的内容。添加子域名后,域名和子域名都会指向子域名。

我究竟做错了什么?

以下是虚拟主机

领域

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName www.domain.com

    DocumentRoot /var/www/domain/
    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>
    <Directory /var/www/domain/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
            # This directive allows us to have apache2's default start page
# in /apache2-default/, but still have / go to the right place
#            RedirectMatch ^/$ /apache2-default/
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
            AllowOverride None
            Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Order allow,deny
            Allow from all
    </Directory>

    ErrorLog /var/log/apache2/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog /var/log/apache2/access.log combined
    ServerSignature On

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

子域名

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName sub.domain.com

    DocumentRoot /var/www/sub/
    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>
    <Directory /var/www/sub/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
            # This directive allows us to have apache2's default start page
# in /apache2-default/, but still have / go to the right place
#            RedirectMatch ^/$ /apache2-default/
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
            AllowOverride None
            Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Order allow,deny
            Allow from all
    </Directory>

    ErrorLog /var/log/apache2/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog /var/log/apache2/access.log combined
    ServerSignature On

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

</VirtualHost>

答案1

我还没有读过配置文件。但我希望你一定要去检查一下 /etc/apache2/sites-enabled

子域名是否与数字相关联域名.com

示例 010-sub 链接到 /etc/apache2/subdomain.conf

和 020-sub 链接到 /etc/apache2/domain.conf

这样 Apache 收到请求后就会首先解析 subdomain.conf。

相关内容