Hello guys, will you please give me a sample code on how to check if the specified url return 404 error.. thanks in advance
You can use a .htaccess rule to redirect to a php script when a page doesn't exist on your site: ErrorDocument 404 http://www.yoursite.com/custom_page.php
Try this: <?php $site = "http://site.com"; $get = file_get_contents($site); if(preg_match('#404#', $get)){ echo "This site has 404 Error"; }else{ echo "This site doesn't have 404 Error"; } ?> PHP:
Creating rule @ .htaccess is best...........here. ---------------------------------- Best website solution @ cheap rates www.seowebindia.com
If using php5 try this: <?php echo '<pre>'; print_r(get_headers('http://www.google.com')); echo '</pre>'; ?> regards
Yes, but it all depends on what he means with a 'specified url'. If it's a url inserted by the user in a form, then you can use PHP to check it. But if it's a url to your site that the user wants to visit (inserted in the address bar of the browser), then you'll have to use .htaccess.