我使用apache2中的“VirtualHost”方法配置了两个站点,但是当我调用我的站点时,如果第一个配置文件出现错误,它就会进入第二个站点。我的配置文件是:
1:音频城堡.现场直播:
<VirtualHost *:80>
Protocols h2
Redirect / https://audio-castle.live
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost *:443>
Protocols h2
ServerName audio-castle.live
ServerAlias www.audio-castle.live
ServerAdmin
DocumentRoot /var/www/audiocastle/web
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/audio-castle.live/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/audio-castle.live/privkey.pem
<Directory /var/www/audiocastle/web>
AllowOverride All
</Directory>
</VirtualHost>
</IfModule>
第二个文件是:gtdvm.com:
<VirtualHost *:80>
ServerName gtdvm.com
Redirect / https://gtdvm.com/
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName gtdvm.com
ServerAlias www.gtdvm.com
ServerAdmin
DocumentRoot /var/www/gtdvm.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/gtdvm.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/gtdvm.com/privkey.pem
<Directory /var/www/gtdvm.com>
AllowOverride All
</Directory>
</VirtualHost>
</IfModule>
问题是,当这两个文件之一出现错误时,例如当我访问 audio-castle.live 时,如果错误出在 audio-castle.live 文件中,我会到达站点 gtdvm.com。我的问题是:当其中一个站点遇到错误时,如何避免从一个站点重定向到另一个站点?我使用 Ubuntu 20.04,apache2.4.46。