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.