fastsol Posted July 7, 2014 Share Posted July 7, 2014 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. Quote Link to comment https://forums.phpfreaks.com/topic/289527-header-declaration-for-unavailable-product/ Share on other sites More sharing options...
KevinM1 Posted July 7, 2014 Share Posted July 7, 2014 It's simple. 404 means not found. Can the product be found at that address? No? 404. Quote Link to comment https://forums.phpfreaks.com/topic/289527-header-declaration-for-unavailable-product/#findComment-1484156 Share on other sites More sharing options...
Solution requinix Posted July 7, 2014 Solution Share Posted July 7, 2014 (edited) 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 July 7, 2014 by requinix 1 Quote Link to comment https://forums.phpfreaks.com/topic/289527-header-declaration-for-unavailable-product/#findComment-1484165 Share on other sites More sharing options...
fastsol Posted July 8, 2014 Author Share Posted July 8, 2014 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. Quote Link to comment https://forums.phpfreaks.com/topic/289527-header-declaration-for-unavailable-product/#findComment-1484204 Share on other sites More sharing options...
requinix Posted July 8, 2014 Share Posted July 8, 2014 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.) Quote Link to comment https://forums.phpfreaks.com/topic/289527-header-declaration-for-unavailable-product/#findComment-1484206 Share on other sites More sharing options...
fastsol Posted July 8, 2014 Author Share Posted July 8, 2014 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 Quote Link to comment https://forums.phpfreaks.com/topic/289527-header-declaration-for-unavailable-product/#findComment-1484216 Share on other sites More sharing options...
requinix Posted July 8, 2014 Share Posted July 8, 2014 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. 1 Quote Link to comment https://forums.phpfreaks.com/topic/289527-header-declaration-for-unavailable-product/#findComment-1484219 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.