How to glue 2 domains on one host?

#1
Hello all,
I need an advice:
I have 2 domain names and I need to point all of this including (www) to one virtual host
i.e.
http:example1.com -> https://example.com
https:/example1.com -> https://example.com
http://www.example.com ->https://example.com
https://www.example1.com -> https://example.com

I have generated a letsecrypt wildcard certificate for second domain example1.com-0001 and created a second virtual hosts with the same host/doc root

my .htaccess in a mutual doc root:

RewriteEngine on
RewriteCond http://example1\.com$ [OR]
RewriteCond https://www\.example1\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com\.ua$ [NC]
RewriteRule ^(.*)$ https://example.com./$1 [R=301,L]

If I curl to http://example1.com or http://www.example1.com it redirects to https://example.com
but for https://example1.com or https://www.example1.com it responces:
curl -I https://example1.com
curl: (60) SSL: no alternative certificate subject name matches target host name 'example1.com'
curl failed to verify the legitimacy of the server and therefore could not establish a secure connection to it.

Please help.
 

Cold-Egg

Administrator
#2
It's two different domains and cert, you may want to set up two virtual hosts and set the cert for each virtual host > SSL
Then you can put a redirect in the example1.com virtual host.
 
#3
It's two different domain and cert, you may want to setup two virtual host and set the cert for each virtual host > SSL
I have separate hosts for 2 domains with the same doc root and wildcard certificates for both.
What else do I need to do?
 
Top