I'm looking for an .htaccess configuration that will redirect all requests to my site to https://www
.
So whether the user visits:
www.example.com
http://example.com
http://www.example.com
https://example.com
They will always end up at:
https://www.example.com
Here is what I am currently using in my .htaccess file, however it doesn't redirect if a user visits:
www.example.com
Here is my current file contents:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule (.*) https://www.example.com/$1 [R=301,L]
I've tried various solutions available on Stack Overflow, but none of them seem to work as intended, often leading to redirect loops. Hopefully someone will have a better understanding of this than I do.