Currently users, going to our www URL get SSL errors, ie "the certificate for this website is invalid". This is because we only have one cert, which is configured for the non-WWW URL: mysite.co
We want requests for either
http://www.mysite.co
https://www.mysite.co
to go to
https://mysite.co
The reverse is acceptable, since our motivation is to minimize costs by paying for only one cert, either www or without www. I did read another post, saying SSL negotiation happens before any response from the server (in our case redirection), so visitors will receive a warning when using a domain that is not in our common name. However, I modified DNS to include a CNAME so that all www.mysite.co traffic redirects to mysite.co and we still see the error in Firefox and Safari
We use Ubuntu with the following mod_rewrite
1) in /etc/apache2/sites-available/mysite-ssl
<VirtualHost *:443>
RewriteEngine on
RewriteCond %{HTTP_HOST} www.mysite.com [NC]
RewriteRule ^(.*)$ https://mysite.com/$1 [R=permanent,L,NC]
ServerAdmin admin@mysite
ServerName mysite
ServerAlias www.mysite
... other stuff ...
</VirtualHost>
2) in /etc/apache2/sites-available/mysite
<VirtualHost *:80>
RewriteEngine on
ReWriteCond %{SERVER_PORT} !^443$
RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R,L]
</VirtualHost>
Interestingly, Chrome says everything fine when going to WWW.mysite.co (both http and https)
However BOTH Firefox and Safari complain of a hostname mismatch (cannot verify identity)