Apache http到https给出重定向循环错误

Apache http到https给出重定向循环错误,apache,.htaccess,mod-rewrite,ssl,https,Apache,.htaccess,Mod Rewrite,Ssl,Https,在my.htaccess文件中: RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L] 当我访问mydomain.io时,Chrome中出现了一个重定向循环错误 我在CloudFlare上设置了免费SSL证书,我不确定这是否会导致问题?当我访问https://mydomain.io它工作正常,并提供了绿色锁和https。请尝试以下规则:

在my.htaccess文件中:

 RewriteEngine On
 RewriteCond %{HTTPS} !=on
 RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
当我访问
mydomain.io
时,Chrome中出现了一个重定向循环错误

我在CloudFlare上设置了免费SSL证书,我不确定这是否会导致问题?当我访问
https://mydomain.io
它工作正常,并提供了绿色锁和https。

请尝试以下规则:


这段代码对我来说很好,而它是我htaccess中的第一条重写规则

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

这似乎适用于Chrome Mac OSX 10.10,但在XP Chrome(虚拟机)上,它给了我一个错误:ERR_SSL_VERSION_或_CIPHER_mistchn不确定问题是什么,但这似乎适用于大多数情况。这仍然给出了一个错误,但下面的cloudflare答案在XP Chrome上除外,无论出于何种原因。@frosty如果同样的错误发生(重定向循环)发生时,您必须在其他地方找到问题(而不是htaccess)
RewriteEngine on
RewriteCond     %{SERVER_PORT} ^80$
RewriteRule     ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]