I have a module that call the Tools::redirect($myurl) function. If I debug in that function (file /classes/Tools.php) :
public static function redirect($url, $base_uri = __PS_BASE_URI__, Link $link = null, $headers = null)
{
if (!$link)
$link = Context::getContext()->link;
if (strpos($url, 'http://') === false && strpos($url, 'https://') === false && $link)
{
if (strpos($url, $base_uri) === 0)
$url = substr($url, strlen($base_uri));
if (strpos($url, 'index.php?controller=') !== false && strpos($url, 'index.php/') == 0)
{
$url = substr($url, strlen('index.php?controller='));
if (Configuration::get('PS_REWRITING_SETTINGS'))
$url = Tools::strReplaceFirst('&', '?', $url);
}
$explode = explode('?', $url);
// don't use ssl if url is home page
// used when logout for example
$use_ssl = !empty($url);
$url = $link->getPageLink($explode[0], $use_ssl);
if (isset($explode[1]))
$url .= '?'.$explode[1];
}
// Send additional headers
if ($headers)
{
if (!is_array($headers))
$headers = array($headers);
foreach ($headers as $header)
header($header);
}
header('Location: '.$url);
exit;
}
setting a die('test'); the line before the header("location"), I have my debug. If I put my test between header() and exit; I still have my test. So far, everything seems normal. Nevertheless, my URL in the variable is http://www.example.com/connexion?back=http://www.example.com/1-my-category and my browser displays a 403 forbidden page. If I cut/paste the URL in the variable, it will display the login form. So, why the header location is not redirecting me to the page ? I'm getting lost...
Solved! The 403 redirection was in the CategoryController in case of user not logged. So I override the controller redirecting to my login page if user is not logged.