If I have a SSL certificate for
https://www.example.com
but not for
https://example.com
I found here that I should use
#First rewrite any request to the wrong domain to use the correct one (here www.)
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#Now, rewrite to HTTPS:
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
for correct redirecting. This seems to work, except for one case:
If I enter https://example.com
then this won't get redirected to https://www.example.com
. Instead I get this:
Is this fixable without buying a SSL certificate for https://example.com
?