I have a website that installed a ssl certificate for the name of www.example.com. It works fine for https://www.example.com. But it doesn't work for https://example.com. The browser gave me Error code: ssl_error_bad_cert_domain.
I am using Apache 2.
I tried to rewrite the url to add www in httpd-ssl.conf, see the code below, but it didn't work. I got the same error code.
<VirtualHost x.x.x.x:443> ServerName example.com ServerAdmin [email protected] DocumentRoot "/var/apache2/example_https" #rewrite to enforce to add www RewriteEngine On RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301] </VirtualHost>
Should I buy a certificate which supports both www.example.com, and example.com? Could it be the only solution?