Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have edited my .htaccess file to redirect any http request to 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

share|improve this question

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

Try this instead:

RewriteCond %{HTTPS} !=on
share|improve this answer
Now it says Moved Permanently. The document has moved here. here refers to "https:///" why??? – Erfan Mar 9 '13 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. – Michael Hampton Mar 9 '13 at 14:58
Thanks, I did that. However, still no luck. – Erfan Mar 9 '13 at 15:06

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.