Htaccess redirect http to https causes redirect loop

.htaccesshttpsredirect

I have edited my .htaccess file to redirect any http request to https://mydomain.se however, this has cause the website to fall in redirect loop. I have looked at the other solutions and compared them however I detected nothing wrong.

RewriteEngine On 
RewriteCond %{HTTP_HOST} ^(www\.)(.+) [OR]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(www\.)?(.+)
RewriteRule ^ https://%2%{REQUEST_URI} [R=301,L]

If it does help, domain is bitech.se

Best Answer

Your RewriteCond seems to always match, as the HTTPS version redirects back to the HTTPS over and over.

Try this instead:

RewriteCond %{HTTPS} !=on