撤消php标头重定向

时间:2014-03-08 12:15:08

标签: php redirect header undo

我在网站上种植EAR个错误。为此,我想撤消我执行的php头重定向。示例: -

if(!admin())
{
  header('Location: www.example.com/non-admin.php');
}

//Some code to undo the redirect happened above

通过撤消上面发生的重定向,它将是易受攻击的。那么有没有可以撤消重定向的机制?

1 个答案:

答案 0 :(得分:1)

请参阅header_remove函数documented on PHP.net

header_remove("Location"); 

如果您使用的是PHP< 5.3,您还可以将header函数传递给第二个参数

header('Location: ', true);

See doc

请注意,标头是在第一次输出之前发送的。通过致电headers_sent()

检查是否已发送