1

My domain is www.supergenscript.com. Its hosted on www.easycloud.us and all DNS has been configured using CloudFlare. I have the following code in my .htaccess file.

RewriteEngine on RewriteCond %{SERVER_PORT} ^80$ RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301] 

Nothing except this there in my .htaccess file. This is the complete code my .htaccess has right now. I am using this code with the purpose to redirect from http to https automatically. Its changing from http to https but the index page is not loading. Instead, the browser keeps on loading and finally after spending some good amount of time it gives an error.

Here is the error received on my Google Chrome browser

This page isn’t working www.supergenscript.com redirected you too many times. Try clearing your cookies. ERR_TOO_MANY_REDIRECTS 

Please help me find a solution to this problem. I am really getting frustrated.

0

2 Answers 2

2

try this:

RewriteCond %{HTTP:X-Forwarded-Proto} !http RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 

above solutions didn't work for me

Sign up to request clarification or add additional context in comments.

1 Comment

This works! I also found out this page that explains HTTP:X-Forwarded-Proto link yet I cannot understand why the original solution, which is way more simple, doesn't work. Is it proxy?
1

Check this one

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

Or This one

RewriteEngine on RewriteCond %{HTTPS} off [OR] RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^ https://www.supergenscript.com%{REQUEST_URI} [NC,L] 

3 Comments

already tried.. same result.. in fact this was the code I tried first.. but changed to the current one when I found it on stack here..
@ShubhamJha Updated my answer please check it will help you :)
Actually easycloud uses CloudFlare for managing DNS and they provide an option to "Always use HTTPS" which I did not know. Just got to know about it. My bad. I just had to enable that option and its working now. But anyways thanks for your help. And since you answer will help those who are just running a custom website without using services like cloudflare, I am going to accept and upvote it. Thanks :)