Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
apache http到https重定向您的次数太多_Apache_Http_Https - Fatal编程技术网

apache http到https重定向您的次数太多

apache http到https重定向您的次数太多,apache,http,https,Apache,Http,Https,我有一个网站。我只想在页面上使用https,因此我查找了.htaccess的代码,发现了以下代码: <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTPS} off RewriteCond %{HTTP_HOST} ^www\.(.*)$ RewriteRule ^(.*)$ https://%1/$1 [L,R=301] RewriteCond %{HTTPS}

我有一个网站。我只想在页面上使用https,因此我查找了.htaccess的代码,发现了以下代码:

<IfModule mod_rewrite.c>
     RewriteEngine On

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

     RewriteCond %{HTTPS} off
     RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>

重新启动发动机
重写条件%{HTTPS}关闭
重写cond%{HTTP_HOST}^www\(.*)$
重写规则^(.*)$https://%1/$1[L,R=301]
重写条件%{HTTPS}关闭
重写规则(.*)https://%{HTTP_HOST}%{REQUEST_URI}[R=301,L]
在将代码添加到my.htaccess后,我重新加载页面,并得到一个错误:重定向您的次数太多

从.htaccess中删除代码后,我重新加载了页面。它很好用。如果我手动重新加载带有https的页面,它也可以正常工作

那我为什么会出错呢


谢谢你的帮助

我运行时遇到了同样的问题,我使用了一个更简单的
代码解决了问题。htaccess

Options +FollowSymLinks
RewriteEngine on

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

我运行时遇到了同样的问题,我使用了一个更简单的
.htaccess
代码解决了问题:

Options +FollowSymLinks
RewriteEngine on

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

你知道为什么会这样吗?是的,这是从我的软件到旧URL的重定向。因此,我的软件需要http,并从ssl重定向,而htaccess希望再次重定向到https。您是否了解发生这种情况的原因?是的,这是从我的软件重定向到旧URL。因此,我的软件需要http,并从ssl重定向,而htaccess希望再次重定向到https。