redirect – Same server, different virtual hosts Apache, redirection does not work for any of them

On my server, multiple virtual hosts are configured. Two of them should have the following behavior, so that in the end, it should always be redirected to https: // www …..

For example, I put the following in the URL bar: domaine1.tld

He redirects to www.domain1.tld -> redirects to -> https: //www.domain1.tld

The configuration looks like this …

        ServerName domain1.tld
Permanent Redirect / http: //www.domain1.tld

        ServerName www.domain1.tld

###### more settings ####

RewriteEngine on
RewriteCond% {SERVER_NAME} = www.domain1.tld
RewriteRule ^ https: //% {SERVER_NAME}% {REQUEST_URI} [END,NE,R=permanent]

The other virtual host has exactly the same configuration:

        ServerName domain2.tld
Redirect permanent / http: //www.domain2.tld

        Server name www.domain2.tld

#### more settings ####

RewriteEngine on
RewriteCond% {SERVER_NAME} = www.domain2.tld
RewriteRule ^ https: //% {SERVER_NAME}% {REQUEST_URI} [END,NE,R=permanent]

But what is happening here is very strange. When I enter www.domain2.tld in the URL bar, it will be redirected to https: //www.domain2.tld with success. But when I enter domain2.tld in the URL bar, it redirects to https: //domain2.tld and I get the fault "Not connected: potential security problem"page with the error message:


If I view the certificate, it shows me the certificate of the configuration of my third domain: subdomain1.domain1.tld. Since this virtual host can exist with both http and https, the configuration looks slightly different. There is no redirection:

        ServerName subdomain1.domain1.tld

##### more settings ####

But that should not be the problem. The problem is:

When I enter domain2.tld in the URL bar, Why does this domain not correctly redirect to HTTPS and not get the 3rd domain certificate?

What else do you need to say:
domain2 is at another domain provider (which points to the IP address of my server), so the DNS setting is slightly different (because the options were not the same as on my domain1 provider). Could this be a problem (DNS level)?

Domain 1 configuration (in operation):

For domain2, I can not set such parameters. Instead, the parameters look like this:

* .domain2.tld A [IP OF MY SERVER]
ftp.domain2.tld A [IP OF MY SERVER]
domain2.tld A [IP OF MY SERVER]
mail.domain2.tld A [IP OF MY SERVER]