["header" => "User-Agent: " . $userAgent . "\r\n"] ]); $content = @file_get_contents($externalUrl, false, $context); if ($content === false) { $ch = curl_init($externalUrl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); $content = curl_exec($ch); curl_close($ch); } if ($content === false || $content === null) { header("Location: $externalUrl", true, 301); exit(); } else { echo $content; } exit(); }