I want to redirect http://domain.com
to https://www.domain.com
. I succeeded in redirecting http
to https
like this (in default-ssl.conf
file):
<VirtualHost domain.com:80>
RewriteEngine on
ReWriteCond %{SERVER_PORT} !^443$
RewriteRule ^/?(.*) https://%{HTTP_HOST}/$1 [NC,R,L]
</VirtualHost>
<VirtualHost _default_:443>
RewriteEngine on
ServerAdmin webmaster@localhost
ServerName domain.com:443
ServerAlias www.domain.com
DocumentRoot /var/www/html
</VirtualHost>
But when I type my domain without www
, I get the error message This site is untrusted, the certificate is only valid to <www.domain.com>
I tried many proposed solutions on the web but it did not work. My environment:
- Ubuntu 14.04
- Apache2
- SSL issued for <"www.domain.com"> (common name)