if($_SERVER['HTTP_REFERER'] != "http://www.example.com/*"){ header("location: http://www.example.com/"); }