Checking if a link is valid
| From: | Christoph Starkmann | Date: | Tue, 02 Apr 2002 11:17:33 +0000 |
| Subject: | Checking if a link is valid | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-91101@lists.php.net to get a copy of this message | ||
Hi there!
This is a general networking problem, I guess...
$fp = fsockopen ($tempUrl, $tempPort, &$errno, &$errstr, 30);
// variables are fine, it works in most cases...
if ($fp)
{
fputs ($fp, "GET / HTTP/1.0\r\n\r\n");
$code = fgets($fp,1024);
$code = str_replace("HTTP/1.1 ", "", $code);
$code = (int)$code;
echo $code;
fclose($fp);
echo " <a href=\"" . $url . "\">" . $tempName .
"</a><br>";
}
I just have my code that does an fsockopen on a
webpage. This works just fine, and in most cases
I can extract the error code (404,200 etc.).
But now I experienced the following strange behaviour:
When trying this on a domain that is automatically
redirected by the provider, I just get a 404.
If I adress this site with my browser, I get
redirected and everything works fine.
The url in this case is http://www.gruppe-69.de/
't is redirected by my provider directly to
http://www.gruppe-69.com
but my linkchecker thinks it would be dead
(404)
Any idea how I can check this, too?
Thanx and cheers,
Kiko
-----
It's not a bug, it's a feature.
christoph starkmann
mailto:kiko@nfq.de
http://www.fh-augsburg.de/~kiko
ICQ: 100601600
-----