Page 1 of 1

301 Moved Permanently Script

Posted: Thu Dec 23, 2004 7:31 pm
by Mr Tech
I want to write a script that cheks whether the URL they entered is "301 Moved Permanently".

What code would I need to find out if its a 301 redirect page?

Cheers

Posted: Thu Dec 23, 2004 11:59 pm
by rehfeld

Code: Select all

<?php

$moved_permanent = false;

$url = 'http://foo.com';

$fp = fopen($url, 'r');

foreach ($http_response_header as $header) {
    if (false !== strpos($header, '301')) {
        $moved_permanent = true;
        break;
    }
}

?>
yes, the variable $http_response_header appears out of thin air