I have several domains for a website that is running on a digitalocan droplet:
my-domain.de
mydomain.de
my-domain.com
mydomain.com
I also installed a letsencrypt ssl certificate.
My goal is that the domain https://www.my-domain.de is my main domain and all other versions redirect permanently to this one.
What works: When i enter some of the non https domains (http://mydomain.de) the redirect works well and the browser shows https://www.my-domain.de.
What not works yet: When i enter a https domain (https://mydomain.de) there is no redirect and the browser shows a certificate warning like "the page is not secure".
This is my virtual host configuration:
# my-domain.de.conf
<VirtualHost *:80>
ServerName www.my-domain.de
ServerAlias my-domain.de
ServerAlias www.mydomain.de
ServerAlias mydomain.de
ServerAlias www.my-domain.com
ServerAlias my-domain.com
ServerAlias www.mydomain.com
ServerAlias mydomain.com
Redirect permanent / https://www.my-domain.de
</VirtualHost>
# my-domain.de-le-ssl.conf
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin admin@my-domain.de
ServerName www.my-domain.de
DocumentRoot /var/www/domain/release/public
<Directory /var/www/domain/release/public/>
...
</Directory>
...
SSLEngine On
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/www.my-domain.de/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/www.my-domain.de/privkey.pem
</VirtualHost>
The problem is that I am not able to define a redirect rule for the https pages. When I try do define a new VirtualHost 443 Block for the redirection from https://mydomain.de to https://www.my-domain.de the whole page is down and not reachable. What do I have to do fix this redirect issue?