Php 在SocialEngine 4.2.9中将htaccess修改为https重定向后,重定向过多会出现[redirect loop]

Php 在SocialEngine 4.2.9中将htaccess修改为https重定向后,重定向过多会出现[redirect loop],php,regex,.htaccess,socialengine,Php,Regex,.htaccess,Socialengine,最近,我为我们的域安装了ssl证书。作为https安全重定向的一部分,将htaccess更改为重定向到https。它与主页配合得很好。但是,当我以用户或管理员身份登录时,重定向失败,并且由于https和http之间的重定向循环而无法获得消息,例如太多重定向和页面加载。请帮我解决这个问题 请查找我正在使用的当前htaccess文件 <IfModule mod_rewrite.c> Options +FollowSymLinks RewriteEngine On Rewri

最近,我为我们的域安装了ssl证书。作为https安全重定向的一部分,将htaccess更改为重定向到https。它与主页配合得很好。但是,当我以用户或管理员身份登录时,重定向失败,并且由于https和http之间的重定向循环而无法获得消息,例如太多重定向和页面加载。请帮我解决这个问题

请查找我正在使用的当前htaccess文件

<IfModule mod_rewrite.c>
  Options +FollowSymLinks
  RewriteEngine On

  RewriteCond %{SERVER_PORT} 80
  RewriteRule ^(.*)$ https://www.flatparty.com/$1 [R,L]

  RewriteRule ^(blog)($|/) - [L]

  # Get rid of index.php
  RewriteCond %{REQUEST_URI} /index\.php
  RewriteRule (.*) index.php?rewrite=2 [L,QSA]

  # Rewrite all directory-looking urls
  RewriteCond %{REQUEST_URI} /$
  RewriteRule (.*) index.php?rewrite=1 [L,QSA]

  # Try to route missing files
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} public\/ [OR]
  RewriteCond %{REQUEST_FILENAME} \.(jpg|gif|png|ico|flv|htm|html|php|css|js)$
  RewriteRule . - [L]

  # If the file doesn't exist, rewrite to index
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?rewrite=1 [L,QSA]

</IfModule>

选项+FollowSymLinks
重新启动发动机
重写cond%{SERVER_PORT}80
重写规则^(.*)$https://www.flatparty.com/$1[R,L]
重写规则^(博客)(元/)-[L]
#去掉index.php
重写cond%{REQUEST_URI}/index\.php
RewriteRule(.*)index.php?rewrite=2[L,QSA]
#重写所有查找目录的URL
重写cond%{REQUEST_URI}/$
RewriteRule(.*)index.php?rewrite=1[L,QSA]
#尝试路由丢失的文件
重写cond%{REQUEST_FILENAME}-F
RewriteCond%{REQUEST_FILENAME}public\/[或]
重写cond%{REQUEST|u FILENAME}\(jpg | gif | png | ico | flv | htm | html | php | css | js)$
重写规则[L]
#如果文件不存在,请重写为索引
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)$index.php?重写=1[L,QSA]

当我访问时,它工作正常。但一旦我登录,就会出现重定向问题。

在htaccess文件中添加以下代码

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

我终于解决了这个问题!!。这不是.htaccess内容的问题,而是服务器代码的问题。以下代码是重定向循环问题的原因

$host = $_SERVER['HTTP_HOST'];
$request_uri = $_SERVER['REQUEST_URI'];
$good_url = "http://" . $host . $request_uri;

header("HTTP/1.1 301 Moved Permanently");
header("Location: $good_url");
.htaccess代码工作正常,每当htaccess将url重定向到https,并且上述代码被重定向到http,最终导致无限循环,请求将永远不会完成


感谢您的帮助和建议。

向我们展示.htaccess内容可能会有所帮助。请查找htaccess。是否可能此社交引擎软件中存在重定向回http的内容?就像一个“站点URL”设置,它将当前URL与之进行比较,如果不匹配则重定向?如果我打印语句“$this->view->siteUrl()”,即使我将htaccess更改为重定向到https,它也会始终返回可能您的apace重写模块已禁用?重写模块已启用,这就是站点重定向到https的原因。但我猜在内部,一些重定向可能发生在代码中,这就是为什么出错太多重定向出错的原因。