简体   繁体   中英

Htaccess rules http to https redirecting too many times

I am using simple htaccess rules to redirect http to https but it breaks the page and shows an error "Redirecting too many times" . Here is my code

Approach -1

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

Approach -2

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

I tried both approaches but its not working. Here is the error i get:

在此处输入图片说明

You either have additional redirects that match similar conditions in your .htaccess or you are using a reverse proxy such as Cloudflare that also does https redirection.

Comment out your rewrite rules and sort them by the order that you want them to execute in the order of "general/generic" to "specific". Un-comment them one at a time and test them.

Disable the https redirects built into your reverse proxy to test.

If you manage virtual hosts you may want to check at that level as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM