BishBashBosh Posted January 29, 2013 Share Posted January 29, 2013 Hi, I am a bit of a noob when it comes to PHP so please bear with me. I can edit a bit, but I find it a bit trickier to write and I need a bit of advice. I manage a website for a friend of mine and they have had the site coded in PHP. I noticed that the site content was loading up correctly but Google is telling me that the pages cannot be found in Webmaster Tools. Upon investigation, I found that there was a 400 header response being served on every page via the header.php file: $found=0; $conn = connectToDatabase(); $results = mysql_query("SELECT * FROM pages WHERE url = '$current_page';", $conn) or die("Error while running query:<br /><br />".mysql_error()); if(($result = mysql_fetch_array($results)) != NULL) {$found=1; $meta_desc=$result['meta_desc']; $meta_keywords=$result['meta_keywords']; $header_title=$result['title'];} if ($found==0) {header('HTTP/1.0 404 Not Found');} As I mention, I am no genius when it comes to PHP, but I changed the {header('HTTP/1.0 404 Not Found');} to {header('HTTP/1.0 200 Ok');} which solved the indexing issue for the pages within Google. However, I now have an issue with soft 404 errors whereby the error page is displayed for incorrect URL's, but they return a 200 response code. I am guessing that my change (although it papered the crack) was not the correct course of action. I have looked at other posts with similar issues but I have not been able to solve the issue. Can somebody point me in the right direction please? Thanks for your patience in advance. Quote Link to comment https://forums.phpfreaks.com/topic/273796-soft-404-header-response/ Share on other sites More sharing options...
requinix Posted January 29, 2013 Share Posted January 29, 2013 By the way: PHP will send a 200 OK by default so you don't actually have to specify that. Also by the way: when posting PHP code please use or [code=php:0] tags. [[ic][/ic]quote]s pale in comparison. It looks like sending a 404 at that point is the right behavior. Search engines really shouldn't be indexing empty/non-existant pages. Google is telling you that there are 404s not because you have them but because there are links going to them. Those links (if they're on your site) are what you need to fix - not the code. Quote Link to comment https://forums.phpfreaks.com/topic/273796-soft-404-header-response/#findComment-1409027 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.