I want to redirect www.example.com or example.com to https://www.example.com
I've tried
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
But it gives me an error ERR_TOO_MANY_REDIRECTS
I also tried
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(example\.com)(:80)? [NC]
RewriteRule (.*) https://www.example.com/$1 [R=301,L]
order deny,allow
It works fine for example.com,
but not for www.example.com