Jump to content

Archived

This topic is now archived and is closed to further replies.

fastsol

Header declaration for unavailable product

Recommended Posts

I am wonrdering what the best type of http header to declare for a product page the is trying to display a product that is either not active at the moment or no longer available.  Basically is google was trying to reach product-details.php?product-id=50 but that $_GET didn't return any results from the DB, I typically have a message that says "That product does not exist or is unavailable at this time.", but it's just a else{} that is showing that and not declaring any http error like 404. 

 

I don't think 404 would be appropriate though cause I don't want it to be can't find type error I think since the product might just be inactive at the moment.  Maybe I am wrong and it should be a 404 error, or is there a more appropriate error to use?  I am mostly concerned about the http header for search engines since the message I display is more than enough for users on the page.

Share this post


Link to post
Share on other sites

It's simple. 404 means not found. Can the product be found at that address? No? 404.

Share this post


Link to post
Share on other sites

Of the HTTP 1.1 codes, 404 Not Found and 410 Gone are really the only ones related to resources going away (besides the 3xx redirections). The difference is that 410 is "this resource is gone for good and not accessible anywhere else we know of/can redirect you to" while 404 is merely "the resource isn't here right now". In fact, they specifically say to use 404 and not 410 if you don't know that the resource was permanently removed.

Share this post


Link to post
Share on other sites

Here's one last question on this.  I have a custom 404.php page that the htaccess redirects to.  Should I be declaring a 404 error on that page or is that stupid cause the 404 page does exist.  I'm trying to wrap my head around what the browser / googlebot is seeing and how it's interpreting that redirect.

Share this post


Link to post
Share on other sites

It's not just about files but the thing(s) represented by the URL. As Kevin said, if the page references a product that does not exist then send a 404.

You should not redirect to the 404 page as that sends a 300-level response (original page -> 3xx -> error page -> 404), but you can rewrite to it (via mod_rewrite sans-[R] or ErrorDocument with a filename) and that's where the 404 should come in.

 

So here it is: if I go to a page, what response do I get back? If it's a 404 then that's good. If it's a 3xx redirect to a 404 page then that's bad. If it's a 200 then that's bad. (Not meaning "harmful" bad, merely "not what it should be doing" bad.)

Share this post


Link to post
Share on other sites

This is the line in the htaccess that I use to redirect for 404s

ErrorDocument 404 /404.php

So I think you're saying that that is good enough and the correct way to do it?  The 404.php would return a normal 200 since it does exist.  You can test it yourself by say going to http://remotelystartedmn.com/what.php which will bring you to http://remotelystartedmn.com/404.php

Share this post


Link to post
Share on other sites

With the caveat that "how it is working right now is correct",

 

The 404.php would return a normal 200 since it does exist.

No. It should return a 404 because the product I requested does not exist. The fact that you're using a real file to respond to my request is irrelevant: the thing I wanted is not there.

Share this post


Link to post
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.