Yesterday I upgraded my domain to SSL.
To migrate from http:// to https:// I used the following code in my .htaccess file:
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://www.example.com%{REQUEST_URI} [L,R=301,NC]
At the moment this code is serving the purpose for the following:
http://www.example.com -> https://www.example.com
www.example.com -> https://www.example.com
example.com -> https://www.example.com
I also need it to do the following:
https://example.com -> https://www.example.com
But when I type https://example.com, the page just loads as https://example.com without redirecting to https://www.example.com
This can cause duplicate page problem if google indexes both https://example.com and https://www.example.com.
Please help me with the right code to achieve the all the above.