简体   繁体   English

错误310(net :: ERR_TOO_MANY_REDIRECTS):

[英]Error 310 (net::ERR_TOO_MANY_REDIRECTS):

What is this error: 这是什么错误:

Error 310 (net::ERR_TOO_MANY_REDIRECTS): There were too many redirects.

I use PHP CodeIgniter and library SimpleLoginSecure , this is my code: 我使用PHP CodeIgniter和库SimpleLoginSecure ,这是我的代码:

if ($this->session->userdata('logged_in')) {
    redirect('admin/index');
}

How can I resolve this error? 我该如何解决这个错误?

Regards 问候

I'm guessing you get an infinite redirect loop: you get redirected to admin/index, this same code snippet is run again, redirecting to admin/index ad infinitum. 我猜你得到一个无限的重定向循环:你被重定向到admin / index,这个相同的代码片段再次运行,重定向到admin / index ad infinitum。 You probably want to add a check to that snippet and only do the redirect if you're NOT on the admin/index page. 您可能希望在该片段中添加一个检查,如果您不在管理员/索引页面上,则只进行重定向。

您不应该在类的__construct()中使用redirect()函数。

I just ran into this with a blog I manage and it ended up being a problem with the URLs set in wp_options . 我刚刚使用我管理的博客遇到了这个问题,最终导致wp_options设置的网址出现问题。 We moved the domain of the dev server and while one of domain prefix changes took in the database, the other didn't. 我们移动了开发服务器的域,当域前缀更改之一进入数据库时​​,另一个没有。 If your url is set for http://domain.com , try setting it to http://www.domain.com . 如果您的网址设置为http://domain.com ,请尝试将其设置为http://www.domain.com

Just goes to show it always helps to start with double-checking your settings, both in wp-config.php and the db site settings. 只是去表明,在wp-config.php和db站点设置中重新检查你的设置总是有帮助的。

check maybe you loading "index" page again somewhere in your code when the index page loading. 检查可能在索引页面加载时在代码中的某处再次加载“索引”页面。

redirect('admin/index'); 重定向( '管理员/索引');

My solution: 我的解决方案

$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;
}  

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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