how to check url exist or not server I try with following code but this is not properly working <?php $url = "http://www.exampless.com"; $headers = @get_headers($url); if(strpos($headers[0],'404') === false) { echo "URL Exists"; } else { echo "URL Not Exists"; } ?> PHP: so plz give the script for checking url exist or not.............
The problem is some sites don't send the code 404, they send the code 200 and show you a dynamic 404 page. Try this: <?php #$url = 'http://www.amazon.com/amazon.asdasd'; # Not Exists $url = 'http://www.amazon.com/books-used-books-textbooks/b/ref=sa_menu_bo8?ie=UTF8&node=283155'; // Exists # This strings depends of the language and depends of the site, but the common are: $strings = array('404 Not found', '404 - Document Not Found'); $info = @file_get_contents($url); if(!$info) print 'URL Not Exists'; else { $exists = true; foreach( $strings as $string ) { if( eregi($string, $info) ) $exists = false; } if( !$exists ) print 'URL Not Exists'; else print 'URL Exists'; } ?> PHP:
I mean if any site or domain are available for example :http://youngangels.in and one incorrect domain for example : http://youngang_els.in which are not correct then his script show the both url valid whenever http://youngang_els.in are not correct but script show this is valid..... how can solve this problem ??????????