I am trying to redirect both versions of Domain-A (HTTP and HTTPs) to another domain Domain-B. Pretty simple stuff but not that simple.
See what i am currently doing now:
<VirtualHost *:80> ServerName DOMAIN-A.com ServerAlias www.DOMAIN-A.com RewriteEngine on RewriteRule (.*) http://DOMAIN-B.com? [R=301,L] </VirtualHost> <VirtualHost *:443> ServerName DOMAIN-A.com ServerAlias www.DOMAIN-A.com RewriteEngine on RewriteRule (.*) https://DOMAIN-B.com? [R=301,L] </VirtualHost> <VirtualHost *:443> ServerName DOMAIN-B.com DocumentRoot /var/www/DOMAIN-B/html SSLEngine on SSLCertificateFile "/etc/letsencrypt/live/DOMAIN-B/cert.pem" SSLCertificateKeyFile "/etc/letsencrypt/live/DOMAIN-B/privkey.pem" SSLCertificateChainFile "/etc/letsencrypt/live/DOMAIN-B/chain.pem" </VirtualHost> Requests to HTTP (Port 80) DOMAIN-A to DOMAIN-B as expected
Requests to HTTPS (Port 443) DOMAIN-A do not redirect, instead gives me SSL certificate error. As DOMAIN-A does not have a SSL is presenting my default server certificate instead of redirecting. (SSL BAD DOMAIN) When I accept the exception in browser then it redirects.
Question ***
Can you see any error on my vhost file? or do I need to create an SSL certificate for a domain I am redirecting? any easier workarounds?
Many thanks