Jump to content


Photo

Header declaration for unavailable product


Best Answer requinix, 07 July 2014 - 02:02 PM

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. Go to the full post


  • Please log in to reply
6 replies to this topic

#1 fastsol

fastsol

    Advanced Member

  • Members
  • PipPipPip
  • 491 posts
  • LocationMinnesota

Posted 07 July 2014 - 09:49 AM

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.


You never know everything, I learn everday!

http://amecms.com

http://amewebdesigns.com


#2 KevinM1

KevinM1

    Snarkimus Prime

  • Moderators
  • 5,235 posts
  • LocationNew Hampshire, USA

Posted 07 July 2014 - 12:54 PM

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

#3 requinix

requinix

    Transforming Moderator

  • Moderators
  • 6,149 posts
  • LocationWA

Posted 07 July 2014 - 02:02 PM   Best Answer

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.

Edited by requinix, 07 July 2014 - 02:03 PM.


#4 fastsol

fastsol

    Advanced Member

  • Members
  • PipPipPip
  • 491 posts
  • LocationMinnesota

Posted 07 July 2014 - 07:40 PM

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.


You never know everything, I learn everday!

http://amecms.com

http://amewebdesigns.com


#5 requinix

requinix

    Transforming Moderator

  • Moderators
  • 6,149 posts
  • LocationWA

Posted 07 July 2014 - 07:57 PM

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.)

#6 fastsol

fastsol

    Advanced Member

  • Members
  • PipPipPip
  • 491 posts
  • LocationMinnesota

Posted 07 July 2014 - 09:55 PM

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


You never know everything, I learn everday!

http://amecms.com

http://amewebdesigns.com


#7 requinix

requinix

    Transforming Moderator

  • Moderators
  • 6,149 posts
  • LocationWA

Posted 07 July 2014 - 10:16 PM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com