Forum Moderators: coopster

Message Too Old, No Replies

Proper action for a page from a database that doesn't exist.

         

BarryStCyr

11:45 pm on Oct 3, 2005 (gmt 0)

10+ Year Member



What is the proper action to take when a user accesses a page from a database that doesn't exist.

For example:

User accesses
http://www.example.com/parts/pn12345.html

which translates to
http://www.example.com/parts/lookup.php?ID=12345

where part number 12345 is not in the database.

I would think 404 would be the proper response, but I need to redirect to another page. I have a parts index that I want the user taken to without having to click on anything.

Thanks
Barry

elgumbo

9:25 am on Oct 4, 2005 (gmt 0)

10+ Year Member



I normally just show a nice "We're sorry but that product appears to have been removed from our stock list. Please choose another item from the list below or contact us for further information."

After all, they could be following a link from search engine for a product that you no longer sell. I wouldn't want people getting a Page Does Not Exist error in that case.

You could also add a javascript or meta refresh to take them to your parts index page.

dmmh

1:05 pm on Oct 4, 2005 (gmt 0)

10+ Year Member



I just use a meta refresh for all non-existing pages, echo out an error message, the redirect them to the main page :)

jd01

5:46 pm on Oct 4, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you are trying to rank in SEs a 404 is the proper response...

if(!isset($result) OR empty($result)) { header($_SERVER['SERVER_PROTOCOL']." 404 Not Found"); exit(); }

You could use a timed refresh to another page, or you could turn this into a custom error page, by serving information after the 'Not Found' header rather than exiting.

There have been some large issues with sites not serving 404s when they should -- I am not the only one, but here is an example: one of my sites got 'stuck' in the indexing process (Google:~400 out of 18K pages and Y ~1800 out of 18K pages -- they were at these numbers for months) within 2 weeks of serving 404s G had the entire site, and Y started adding 200 pages every couple of days. I guess they like it when webmasters communicate with them properly.

One of the other issues noted, is people are having their 404 page (custom) indexed, because they are not serving a 404 (most of the time end users receive a 302 instead)... they have reported having hundreds of non-existent URLs indexed and credited to their site. Since the SEs did not get a 404 message, they 'thought' the custom error page was really duplicated at every non-existent URL they requested -- needless to say those site owners have some duplicate content issues now.

Justin