这是什么错误:
Error 310 (net::ERR_TOO_MANY_REDIRECTS): There were too many redirects.
我使用 PHP CodeIgniter 和库SimpleLoginSecure,这是我的代码:
if ($this->session->userdata('logged_in')) {
redirect('admin/index');
}
如何解决此错误?
问候
这是什么错误:
Error 310 (net::ERR_TOO_MANY_REDIRECTS): There were too many redirects.
我使用 PHP CodeIgniter 和库SimpleLoginSecure,这是我的代码:
if ($this->session->userdata('logged_in')) {
redirect('admin/index');
}
如何解决此错误?
问候
我猜你得到一个无限的重定向循环:你被重定向到 admin/index,同样的代码片段再次运行,无限重定向到 admin/index。您可能希望对该片段添加一个检查,并且仅当您不在管理/索引页面上时才进行重定向。
你不应该在你的类的 __construct() 中使用 redirect() 函数。
我的解决方案:
$self = $_SERVER['PHP_SELF'];
$str2use = strrchr($self, '/');
$length = strlen($str2use) -1;
@$fname = substr($str2use, 1, $length);
if ($fname != "YOURPHPSCRIPT.php"){
echo "<script>window.location='YOURPHPSCRIPT.php';</script>";
exit;
}
我刚刚在我管理的博客中遇到了这个问题,结果是在wp_options
. 我们移动了开发服务器的域,虽然其中一个域前缀更改进入了数据库,但另一个没有。如果您的 url 设置为http://domain.com
,请尝试将其设置为http://www.domain.com
.
只是表明它总是有助于从仔细检查您的设置开始,包括在wp-config.php
和数据库站点设置中。
检查也许你在加载索引页面时再次在代码中的某处加载“索引”页面。
重定向('管理员/索引');