Change the default timeout, then redirect on failure.
You can change the default timeout used for file_get_contents
like so:
ini_set('default_socket_timeout', 10); // 10 seconds
We need to do this, because the default timeout is 60 seconds - and your visitors won't want to wait that long.
Then you just test if the request went ok, and redirect based on that...
$request = file_get_contents($url);
if( !$request )
header("Location: http://someurl.com/");
exit;
(Remember to exit after a redirect, or sometimes code after that still gets executed).