php 错误 310(网络::ERR_TOO_MANY_REDIRECTS):

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6911808/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 01:35:16  来源:igfitidea点击:

Error 310 (net::ERR_TOO_MANY_REDIRECTS):

phpsessioncodeigniterredirectuser-data

提问by Kimberly Mullins

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

问候

回答by Richard H

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. You probably want to add a check to that snippet and only do the redirect if you're NOT on the admin/index page.

我猜你会得到一个无限的重定向循环:你被重定向到 admin/index,同样的代码片段再次运行,重定向到 admin/index 无限循环。您可能希望对该代码段添加检查,并且仅在您不在管理/索引页面上时才执行重定向。

回答by jamesxu-e.g.

You should not use redirect() function in your class's __construct().

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

回答by ntthushara

check maybe you loading "index" page again somewhere in your code when the index page loading.

检查是否您在加载索引页面时在代码中的某处再次加载了“索引”页面。

redirect('admin/index');

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

回答by Joel Hernandez

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

回答by kristina childs

I just ran into this with a blog I manage and it ended up being a problem with the URLs set in 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.

我刚刚在我管理的博客上遇到了这个问题,结果是wp_options. 我们移动了开发服务器的域,而其中一个域前缀更改发生在数据库中,而另一个则没有。如果您的网址设置为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.phpand the db site settings.

只是表明它总是有助于从仔细检查您的设置开始,包括wp-config.phpdb 站点设置。