What are the best practices for handling server responses, especially in cases where mod_rewrite or similar techniques are used, when checking webpage availability in PHP?

When handling server responses, especially when using mod_rewrite or similar techniques, it is important to check for the HTTP response code to determine the availability of a webpage. In PHP, you can use the `get_headers()` function to retrieve the headers of a URL and then check the HTTP response code to see if the webpage is available or not.

$url = 'http://example.com/page';
$headers = get_headers($url);

if(strpos($headers[0], '200') !== false) {
    echo 'Webpage is available';
} else {
    echo 'Webpage is not available';
}