I have multiple domains, but I have only one certificate. I have created two virtualhost's, one with certificate for domain: domain.lt second with redirects to domain.lt
Apache's SSL config:
<IfModule mod_ssl.c>
<VirtualHost *:443>
<Directory "/var/www/html">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ServerName domain.lt
ServerAlias www.domain.lt
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/domain.lt/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/domain.lt/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
<Directory "/var/www/html/main/wp-content/uploads/">
Options -Indexes
</Directory>
</VirtualHost>
<VirtualHost *:443>
<Directory "/var/www/html">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ServerName domain.pk
ServerAlias www.domain.pk
ServerAlias domain.fi
ServerAlias www.domain.fi
ServerAlias domain.eu
ServerAlias www.domain.eu
ServerAlias domain.hk
ServerAlias www.domain.hk
ServerAlias domain.ae
ServerAlias www.domain.ae
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?domain.(pk|fi|eu|hk|ae)$
RewriteRule ^(.*)$ https://domain.lt%{REQUEST_URI} [L,R=301]
</VirtualHost>
</IfModule>
But I'm still getting warnings in browser that the connection is not secure and the certificate is only for domain.lt. After adding exception in browser I'm being redirected. How can i accomplish that?