Why does my website give 404 errors for pages that exist and are accessible?

Peter Iranha picture Peter Iranha · May 4, 2011 · Viewed 9.3k times · Source

My problem is that on certain pages on my website such as http://www.piranha-internet.co.uk/web/website-design.php I am been served with a 404 error in Google Webmaster Tools. However I can access the pages normally, they all have links pointing to them internally, non yet from external.

  • I have done header checks on this page and get served a 404 as well.
  • I have created blank files on my server and they seem fine giving me a 200 code but if I duplicate and rename the 404 files in question I get the same 404 errors.
  • I have roughly 40 pages on my site, half of which give 200 code and half 404. They all use the same structure & same includes but the content is different on all of them.

Why is this happening?

Answer

Dan Karas picture Dan Karas · Jun 3, 2012

I had the same problem when I tried to include my wordpress header at the top of the code before the HTML

<?php
    include('blog/wp-blog-header.php');
?>

The pages worked but Google saw a 404 and wouldn't index the pages.

Solved the problem by moving the PHP include inside the body of the HTML.

Weird problem...

Dan