Welcome to WebmasterWorld Guest from

Forum Moderators: phranque

Message Too Old, No Replies

What error should I send if the page does not exist?

Should it be a 404 error or a 400 error?

7:02 am on Jan 3, 2007 (gmt 0)

Preferred Member

10+ Year Member

joined:Aug 12, 2005
votes: 0

I have a dynamic page that will GET variables from the URL and check them against a database.


If no article variable is express, a directory loads.

If an article variable is expressed, and this article is in the directory, the article loads.

If an article variable is expressed, but this article is not in the directory, they get an error page suggesting they check their spelling, or go to the article directory.

I plan on sending an error code in the header for this last scenario, but I'm debating which error code I should use.

I would normally assume a 404 error, because that's what I'm use to seeing.

I did some research on w3:


A 404 Error means that the server hasn't found anything that matches the request (which in my case is true).

It continues to say that "no indication is given of whether the condition is temporary or permanent" (which could also be the case because I might add an article in the future that uses that name).

However, it also adds that "this status code is commonly used when the server does not wish to reveal exactly why the request has been refused, or when no other response is applicable". That seems like a general catch all. I know why the request was refused, maybe there is a better response to give?

On the other hand, a 400 error says that "the request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications".

This seems to be true. The error occurred because of a wrong URL (possibly misspelled), and if you try the request again, you'll get the same error.

The thing is, I've never strayed away from 404s before, and I'm wondering if I'm giving out the wrong code that might have unintended consequences (with browsers, bots or search engines). Which of these codes should I give? Or maybe there is another, more appropriate code.

Any advice is greatly appreciated! Thanks.

12:15 pm on Jan 3, 2007 (gmt 0)

Senior Member from NL 

WebmasterWorld Senior Member lammert is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Jan 10, 2005
votes: 35

A 404 is the correct error code for a non-existent page. The 400 should only be sent when the syntax of the request is invalid. For a non-existent page, the HTTP server is still able to parse and understand the request, but it cannot match the URL to an existent file or dynamic database object. I.e. the syntax is correct, but the matching fails.

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members