Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have this use case that happens frequently:

Lots of products for sale, periodically a percentage goes out of stock.

A user still browses in on the old url, to a location where a product used to be.

I want to redirect them to a search page, and notify them that the product is no longer available, and try to provide them with alternatives.

At the same time, I want to notify automated services (search engines, shopping engines) that that specific product is gone, in order to prevent continued hits to the urls in question.

What ways are there for gracefully handling this?

Edit: I'm refactoring/recoding the site in custom php code. I also do have a dedicated 404 page, with links to places on the site, etc, but don't really want to duplicate the search page's functionality on the 404 page when a system is already in place in a different php script, and for most 404's I already have a more generic suggestion for alternatives.

share|improve this question
For reference, I also found this: google.com/support/forum/p/Webmasters/… link which talks about google's approach to 404 vs. 410, wherein they view 410 as a slightly more purposeful event, and a 404 as a slightly more random occurance. – Kzqai Sep 2 '11 at 16:55
up vote 2 down vote accepted

You've put the 404 tag on the question whereas a page that returned a 410 ("Gone") error code would be better. For PHP you can do it like this:

header("HTTP/1.1 410 Gone");

before you start doing other output.

Your question is similar to this Is it better to have an ErrorDocument 404 redirect back to the homepage or a standard 404 error page? but the accepted answer for that suggests what sounds like one page, whereas your idea of a page which provides alternatives implies there are lots of them, one for each out of stock product.

share|improve this answer
+1. Just "410 Gone" response would be more appropriate than general "404 Not Found" for the product that was on site in the past but no longer there. – LazyOne Sep 2 '11 at 15:23
Thanks, that's true. I've updated my answer. – paulmorriss Sep 2 '11 at 15:32
Yeah, part of my problem is the process. I would think that if I return 404, I can't return a 301 redirect... – Kzqai Sep 2 '11 at 15:50
True, it's one or the other. – paulmorriss Sep 2 '11 at 15:57
@Tchalvak No need for 301 redirect. Display your page (the content you want to show to the user) with 410 code on the same URL (URL for no-more-active/available-product) -- that will be the best for both user and search engine (user will see content/explanation while SE will take Response code). – LazyOne Sep 2 '11 at 15:57

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.