Patrick
Patrick

Reputation: 1

Too many redirection

I have a problem on my page with a result for too many redirection. Do you have an idea to resolve that ? ; ERR_TOO_MANY_REDIRECTS

  if (MODE_VENTE_PRIVEE == 'true') {
    if ( (!$this->customer->isLoggedOn())  && (!strstr($_SERVER['QUERY_STRING'], 'Account&Login')) ) {
      if (
        (!strstr($_SERVER['QUERY_STRING'],'Account&Create')) &&
        (!strstr($_SERVER['QUERY_STRING'],'Account&PasswordForgotten')) &&
        (!strstr($_SERVER['QUERY_STRING'],'Account&CreatePro.php')) &&
        (!strstr($_SERVER['QUERY_STRING'],'Info&contact.php'))
      ) {
        $CLICSHOPPING_NavigationHistory->setSnapshot();

        HTTP::redirect('index.php?Account&LogIn');

      }
    }
  }

the function

public static function redirect($url, $http_response_code = null) {
  if ((strstr($url, "\n") === false) && (strstr($url, "\r") === false)) {
    if ( strpos($url, '&') !== false ) {
      $url = str_replace('&', '&', $url);
    }

    header('Location: ' . $url, true, $http_response_code);
  }

  exit;
}

Upvotes: 0

Views: 91

Answers (1)

AwesomeGuy
AwesomeGuy

Reputation: 1089

The problem is that you're redirecting to Account&LogIn and you're checking for Account&Login which are completely different strings, so you're stuck in a loop. Try this:

if (MODE_VENTE_PRIVEE == 'true') {
  if ( (!$this->customer->isLoggedOn())  && (!strstr($_SERVER['QUERY_STRING'], 'Account&Login')) ) {
    if (
      (!strstr($_SERVER['QUERY_STRING'],'Account&Create')) &&
      (!strstr($_SERVER['QUERY_STRING'],'Account&PasswordForgotten')) &&
      (!strstr($_SERVER['QUERY_STRING'],'Account&CreatePro.php')) &&
      (!strstr($_SERVER['QUERY_STRING'],'Info&contact.php'))
    ) {
      $CLICSHOPPING_NavigationHistory->setSnapshot();

      HTTP::redirect('index.php?Account&Login');

    }
  }
}

Upvotes: 2

Related Questions