I have a couple of sites (on different servers) that I want to see if some critical urls are up and running and this is what I've tried:

$handle = curl_init($url);
curl_setopt($handle,  CURLOPT_RETURNTRANSFER, TRUE);

/* Get the HTML or whatever is linked in $url. */
$response = curl_exec($handle);

/* Check for 404 (file not found). */
$httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE);
if($httpCode == 404) {
    /* Handle 404 here. */
}

curl_close($handle);

This however always returns a redirect to the login page.

How do change the code so that it logs in first and then checks the url?

Cheers
/Adam

If you just want to know if the site is up then doesn't the redirect tell you that the site is up?

Well no, these particular pages might be down even though the site is up and running...