How to redirect if not from $_SERVER['HTTP_REFERER']?
<?PHP
if (开发者_JAVA百科ereg("www\.test", $_SERVER['HTTP_REFERER']) != true)
{
header("location http://www.example.com");
end;
}
echo "111";
//dosomting?
?>
It still not working
Try this:
<?php
if (!preg_match("www\.test", $_SERVER['HTTP_REFERER'])) {
header("Location: http://www.example.com");
exit();
}
//do stuff...
?>
精彩评论