Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
Python, Lua and Tcl - public course schedule [here]
Private courses on your site - see [here]
Please ask about maintenance training for Perl, PHP, Java, C, C++, Ruby, MySQL and Linux / Tomcat systems
Does a particular URL exist?

Posted by admin (Graham Ellis), 24 July 2005
I'm often asked how to check whether a particular URL exists - we assure people there's a function in PHP to do almost anything and yet no single function exists for this purpose. The question cropped up again this morning and here's how I answered

There is no general function to check any URL, but you can check an http:// URL for readability easily enough. The only way to test for mailto: type URLs is to send an email to the URL and see if the owner of the URL responds, and you're not going to find it very easy to check for the existance of http:// web pages within directories for which authorisation is required.

Note that testing a remote URL will cause your enquiry to be recorded in log files that the server there is probably keeping, and that you should respect the robots exclusion standard is you're doing more than a handful of tests.

I've uploaded an example script - VERY carefully filtered and I'll be keeping my eyes on it too - to test URLs.  It's here.   If you visit the script, you'll find that it reveals its own source code (nice, but be careful) and that I've added in a test to make sure that it will only accept http:// type URLs.

Posted by curtis (curtis), 8 October 2005
Nice job

I never thought about checking URLs very much, but it looks like you've come up with a nice, simple method.

On a somewhat related note, if you want to validate links, you can use the W3C's link checker.

This page is a thread posted to the opentalk forum at and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2018: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01225 708225 • FAX: 01225 793803 • EMAIL: • WEB: • SKYPE: wellho