Reputation: 17467
is it possible to use single certificate in apache
for two alias domain name using some kind of redirect using URL rewrite etc? like following. I want to redirect example.com to www.example.com
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com$
RewriteCond %{SERVER_PORT} =443
RewriteRule ^ https://www.example.com%{REQUEST_URI} [L,R=301]
Problem is i have SSL certificate registered for www.example.com
domain and i have CNAME example.com but i am getting SSL warning on example.com, can i use above trick to make it work?
Upvotes: 0
Views: 1365
Reputation: 122719
You can have a certificate valid for multiple host names when it has multiple Subject Alternative Names or when it's a wildcard certificate (or both).
Wildcard certificates are not particularly useful for www.example.com
and example.com
because the dot isn't part of the pattern, so *.example.com
wouldn't match example.com
. Such a wildcard certificate would need an additional SAN for example.com
anyway in this case.
CAs have various commercial names for certificates with multiple SANs, and often charge extra for then.
However, the www
is considered by many a special case. Some CAs will issue a cert with SANs for www.example.com
and example.com
when you apply for www.example.com
, without an extra fee.
You could also use two distinct certificates but, unless you know all your clients support Server Name Indication (SNI), you would need a separate IP address for each.
Upvotes: 1
Reputation: 47965
For security reasons every certificate is limited to a domain. Some certificates are fore a hole bunch of domains like wildcard certificates, such a certificate would slove your problem, but in commem they cost double or trippel of the normal price.
Another way would be a certificate for two domains but this is not very simple to configure. However this certificate needs to be signed by a certificate authority.
So now you cannot do anything except to buy another certificate.
I almost forgot it, you can get free certificates from https://startssl.com/. Not with your name but for a redirect it should be fine.
Upvotes: 1