I have an SSL cert valid for the www.
and .
subdomains on a domain. That's up and working great. All traffic on http
redirects to https
, and all bare domain traffic redirects to the www.
version. In short, everything ends up on https://www.
So far so good.
However, I also have a .com
. That currently has an apache level redirect (can't change DNS currently)
At the moment going to the https://www.***.com
address shows that the certificate isn't valid, which is of course correct – it's only for www
and .
on .co.uk
.
Question
How do I get the https://www.***.com
to redirect to https://www.***.co.uk
without a valid SSL cert for the .com, and without changing the DNS?
Technical details
All domains point to same server. A vhost is set up for the ssl version and non ssl version, both with aliases for www and no www for the .co.uk and .com.
A rewrite rule like:
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
pushes everything to https.
You can't send redirects without a vlid certificate. The redirect is done in either the HTTP protocol by returning a 301 or 302 response, or in html content with a meta header. For this data to be sent, the SSL connection needs to be set up first, with a valid certificate. So don't be ridiculously cheap and get an almost-free startssl certificate for the .com.
And if you don't want to point that domain to a separate IP, you need to set up SNI support in apache to deal with multiple certs on one IP.