I am searching for the perfect 301 redirect HTTP to HTTPS - non-www to www. But I can't find a working solution.
Here is what I want to do
http://domain.tld/ → https://www.domain.tld/
http://www.domain.tld/ → https://www.domain.tld/
https://domain.tld/ → https://www.domain.tld/
In this post: Best Practice: 301 Redirect HTTP to HTTPS (Standard Domain)
It concludes:
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^ https://example.com%{REQUEST_URI} [R=301,L,NE]
but this is for www. to non-www.
Please help.
Thanks,