Peter Iranha
Peter Iranha

Reputation: 63

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

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.

Why is this happening?

Upvotes: 4

Views: 10803

Answers (3)

Dan Karas
Dan Karas

Reputation: 31

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

Upvotes: 3

mellamokb
mellamokb

Reputation: 56769

It appears when I visit http://www.piranha-internet.co.uk/web/website-design.php using Fiddler, I get a 404 HTTP status code returned along with the page content. Somewhere your server, or your code is actually sending a 404 HTTP status code.

Is there a possibility you could show some of your .php source code for the relevant pages, such as website-design.php and the header include files?

Edit:

Could you try a systematic approach: Start with a blank page, that returns a 200 HTTP code. Add lines of HTML / PHP from one of those pages that returns a 404, line by line, and keep testing after each change until you find what change sent it to a 404 instead of a 200. See if you can trace it down to a specific line of code, a specific function call, include etc., and post the result.

Upvotes: 2

hakre
hakre

Reputation: 197624

What you see in GWT is the actual HTTP response code. 404 in your case an it means "Not Found".

By definition this marks the request as "Not found" and that's what GWT reports to you.

Within any PHP script you can set the response code in addition to the output. I have no insight into the code of /web/website-design.php so it's hard to tell what's wrong or if it's wrong at all.

You could look for the use of the header() function within your code. That function can set the response code.

Upvotes: 0

Related Questions