2

I'm struggling putting online CS50 finance site. When I try to access it from internet http://172.16.29.128/pset7/public/login.php I get This webpage has a redirect loop with ERR_TOO_MANY_REDIRECTS. I've completed access changing steps in the beginning of the pset twice... no result and have no idea where the look for a mistake and what can cause such error?

Please advice what can I try to troubleshoot this? or maybe paste here more of my actual code?

Thanks in advance!

enter image description here

1 Answer 1

1

Look in your config.php file (it is in "includes" directory).

'Loop redirect' means that your site redirect the user to another (maybe the same, but still a redirect) page, and the new page redirect again... and the new page redirect again... and the new. You understand.

In the config file you find a script that redirects the user to the login page. Check if there is a condition that prevents redirect when the user is already on the login (or in the register) page.

This is how the config.php looks like: (maybe you corrupted it)

/**
 * config.php
 *
 * Computer Science 50
 * Problem Set 7
 *
 * Configures pages.
 */

// display errors, warnings, and notices
ini_set("display_errors", true);
error_reporting(E_ALL);

// requirements
require("constants.php");
require("functions.php");

// enable sessions
session_start();

// require authentication for all pages except /login.php, /logout.php, and /register.php
if (!in_array($_SERVER["PHP_SELF"], ["/login.php", "/logout.php", "/register.php"]))
{
    if (empty($_SESSION["id"]))
    {
        redirect("login.php");
    }
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .