I configured two sites using the "VirtualHost" method in apache2, but if
there is an error in the first configuration file when I call my site, it
enters the second site. my configuration files are:
1: audio-castle.live:
<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>
the second file is: 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>
the problem is when an error occurs in one of these two files, when I
access for example audio-castle.live, I reach the site gtdvm.com, if the
error is in the audio-castle.live file. my question is: how to avoid this
redirect from one site to another when one of them encounters errors? . I
use Ubuntu 20.04, apache2.4.46.

Reply via email to