How to handle redirects & http status codes at urls where a product becomes unavailable?

How to handle redirects & http status codes at urls where a product becomes unavailable? - If a page has internal and external outgoing links to redirecting URLs, it’s returning 3xx (301, 302, etc.) HTTP status codes standing for redirection. This issue means that the page does not exist on a permanent or temporary basis. It appears on most of the popular web browsers, usually caused by a misconfigured website. However, there are some steps you can take to ensure the issue isn’t on your side. You can find more details about redirecting URLs by reading the Google Search Central overview. In this article, we’ll go over how you can fix the How to handle redirects & http status codes at urls where a product becomes unavailable? error on your web browser. Problem :


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.


Solution :

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.


We hope that this article has helped you resolve the seo, redirects, 404 error in your web browsers. Enjoy browsing the internet uninterrupted!

Comments

Popular posts from this blog

How to redirect to any domain [duplicate]

"302 found" for index page bad for SEO?

Create redirect from url like www.example.us/?p=100&option=