homepage Welcome to WebmasterWorld Guest from 54.205.144.54
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / WebmasterWorld / Webmaster General
Forum Library, Charter, Moderators: phranque

Webmaster General Forum

    
What error should I send if the page does not exist?
Should it be a 404 error or a 400 error?
Jeremy_H




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

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

index.php?article=name

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:

[w3.org...]

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.

 

lammert




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

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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / WebmasterWorld / Webmaster General
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved