1

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

2 Answers 2

1

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

Try this instead:

RewriteCond %{HTTPS} !=on
2
  • Now it says Moved Permanently. The document has moved here. here refers to "https:///" why???
    – Erfan
    Mar 9, 2013 at 14:54
  • You're trying to redirect to https:/// which doesn't actually contain a hostname. Perhaps you should actually use the hostname, instead of %2. Mar 9, 2013 at 14:58
1

I'm using following settings to redirect every HTTP traffic to HTTPS with the exact requested path:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .