In the question htaccess redirect to https://www the answer was basically this:
RewriteEngine On
RewriteCond %{HTTPS} off
# First rewrite to HTTPS:
# Don't put www. here. If it is already there it will be included, if not
# the subsequent rule will catch it.
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Now, rewrite any request to the wrong domain to use www.
# [NC] is a case-insensitive match
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
The second higest upvoted answer stated that if you only have a single certificeted domain that one should reverese the order.
In my case I only have a SSL certificate for https://www.example.com
but not for https://example.com
. I am using the above .htaccess
settings, so I have not reversed the order.
When I enter http://example.com
I expected it to be redirected first to https://example.com
(because of the L
flag) and to throw a warning like
To my surprise, this gets correctly redirected to https://www.example.com
.
Why is this not redirected to https://example.com
and throwing a warning?