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.

  • 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, 2011 at 16:55

1 Answer 1


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.

  • 1
    +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, 2011 at 15:23
  • 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, 2011 at 15:50
  • True, it's one or the other. Sep 2, 2011 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, 2011 at 15:57
  • Hmmm, so instead of a status code of 301 and a location redirection to the search, it would just have a status code of 410 and a redirection to the search, and that would work equivalently?
    – Kzqai
    Sep 2, 2011 at 16:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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