本文介绍了重定向过多的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找不到解决方案.基本上,我们使用的是虚荣网址系统,因此它是user.domain.com.可以访问所有文件,如user.domain.com/home.php等.清除cookie时,重定向将起作用,它会提示它们重新登录.但是,当我使用注销时,它仍然有效,但是当他们返回登录链接时,(user.domain.com在用户的登录页面上有一个登录表单供用户使用)将无法正常工作.我得到的错误是

I can't find the solution to this one. Basically we are using a vanity url system so its user.domain.com. All files are accessed like user.domain.com/home.php etc. When you clear cookies the redirects work, it prompts them to login again. But when i use logout, it still works but when they go back to the link to login, (user.domain.com, has a login form on the landing page for the user) it won't work. The error i get is

错误消息:

              The page isn't redirecting properly



               Firefox has detected that the server is redirecting the request for this address
               in a way that will never complete.


               This problem can sometimes be caused by disabling or refusing to accept
      cookies.

所有会员页面的重定向代码:

Redirect Code for all member pages:

         if(!isset($_SESSION['user_name'])) { header("Location: http://$_SERVER[HTTP_HOST]");}
         Note:  The $_SERVER[HTTP_HOST] captures the user.domain.com value for redirect.

注销代码:

          <?php


            session_start();
            session_destroy();

            header( 'Location: $_SERVER[HTTP_HOST]' ) ;
              ?>

解决此问题的唯一方法是用户清除cookie.

The only way for this issue to go away is if users clear their cookies.

更新:使用logout.php之后,我转到了user.domain.com/home.php成员页面之一,而不是将其重定向到user.domain.com进行登录,这给了我重定向错误.这可能是会话问题还是标题问题?

UPDATE: After using the logout.php i went to one of the member pages user.domain.com/home.php instead of it redirecting to user.domain.com for login it gave me the redirect error. Could this be an issue with the sessions or something with the headers?

我可以增强或添加哪些功能来解决此问题?我尝试了谷歌搜索,但没有发现任何特别的东西.我确实需要一些帮助来解决此问题.谢谢.

What can i enhance or add to fix this? I have tried Googling but haven't found anything particular to this. I really need some help in fixing this. Thanks.

这是我在Safari中收到的错误消息:

This is the error message i get in Safari:

       Too many redirects occurred trying to open "http://user.domain.com/home.php".
      This might occur if you open a page that is redirected to open another page which then is  redirected to open the original page.

推荐答案

浏览器阻止您对服务器进行大量请求.这很可能是由于header()将您发送到一个页面,然后又将您发送到同一页面(或具有相同header()的页面).

The browser is stopping you from hammering the server with a bunch of requests. This is most likely due to the header() sending you to a page which in turn sends you to the same page (or page with the same header()).

这篇关于重定向过多的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 15:38