Force www and https (ssl) in website URL via .htaccess

Having difficulty getting both https (SSL) and www to display in the website URL?
Insert the below code into the .htaccess file in the root folder of your website.
Obviously this requires both and SSL cert to be installed and working correctly, and also that both the www and non www version of your domain are pointing to the same folder on the same server.

[code]
RewriteEngine on
# Force WWW & SSL
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://www.domain.com/$1 [L,R=301]
[/code]

Posted in