I have a website with https://example.com, http://example.com, https://www.example.com and https://www.example.com working fine.
Now I want that regardless of which one you type, it redirects to https://www.example.com. I am using the code below in my .htaccess (and tried many more), but after doing the redirection in the browser the page doesn't load, giving error "Too many redirects". I tried of course deleting cache.
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]