You are here: Re: Get http response codes « PHP Programming Language « IT news, forums, messages
Re: Get http response codes

Posted by rh on 11/02/06 04:36

"Bart op de grote markt" <bartwarnez@freegates.be> wrote in message
news:1162215727.250479.229640@i42g2000cwa.googlegroups.com...
> 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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация