The get_contents file is slightly overfulfilling the target, as it is enough for the HTTP header to make a decision, so you need to use curl to do this:
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.example.com/");
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_exec($ch);
curl_close($ch);
?>
source
share