"Bart op de grote markt" <bartwarnez@freegates.bewrote in message
news:1162215727.250479.229640@i42g2000cwa.googlegr oups.com...
Quote:
Hello
>
I have a website in php in which I have some kind of portal to external
links that come from a database. When a user clicks on a link,
"link.php" is called, does some stuff (e.g. adds 1 to the visit-count
of that certain page) and then forwards the user with a location-header
to the asked page. Now my question: is it possible to get the
response-code of that asked page? E.g. when code 404 is returned, I
can put that in the database and then it's easy for me to know when a
link is broken.
>
Kind regards,
>
Bart
>
Yes.
When link.php "does some stuff" have it send a HEAD request to the link
url.
If it comes back as "200 Ok" forward the user to the page, if it comes back
as "404 Not Found" or any other error response show the user an error page
on your site and log the error for that link.
If the response comes back with a 3** redirect, you could parse that url
and check it (possibly set up a loop to check multiple redirects), forward
the user, or just show an error if you don't want the links to redirect
your users.
Rich