Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email

Magento Forum

Redirect to category if a product is no longer available
Jr. Member
Total Posts:  1
Joined:  2012-03-16

I have a webshop that sells second hand stuf so our products disappear from the website when they are sold. In google my product pages are also indexed so when a client click on this link and the product is already sold they will see a 404 page. How do i redirect this client to the category of this product?

So when i type in second hand wooden table in google my link appear in the results when a client clicks this he will be redirected to the category tables when the product is no longer available.

Or does someone have another solution? No-index my product pages? But I think this is not great for my seo?


I have found this but how do you do this in magento?

“301ing disabled products

Consider this scenario.  You sell a great, useful amazing product, everyone loves it.  They love it so much that the product goes viral and you’ve got thousands of inbound links to it.  A year later, the product is no longer available, and you disable it from your website.  What then happens to users that click on those links?  What happens to search engines the next time they spider your site?  What happens to all that link juice being passed to that page?  The answer to all of the above is… 404

This is a pretty common issue we come across with eCommerce platforms, when products are disabled, and a user tries to go to that now defunct URL, they get a 404 error.  While we do recommend customizing your “not found” pages to at least include a search or related pages, what would be more effective from an SEO perspective, and a user’s perspective is if they got directed to another page that was related to the product that is no longer available.  What we do is actually create a means for which Magento administrators can setup a “redirect to” product (or category) so that when a product is disabled, instead of the user (or search engine) getting a 404, they actually get taken to a product that might have replaced it, a related product, or even the parent category if you no longer carry that product.  This will help retain any search engine positioning that product was getting, preserve any link juice that was being passed to that page, as well as creating a better user experience.  A win all the way around.”

Magento Community Magento Community
Magento Community
Magento Community
Sr. Member
Total Posts:  84
Joined:  2008-10-20

We have the same problem, i don’t want to loose very good inbound links to products that are now disabled.

I did a little digging and found this as starter for testing on a local box..!
If I have good in bound links to /my-category/product.html and that product is disabled, instead of Google getting a 404 page, it points to its category.


right after

public function noRouteAction($coreRoute null)
->getResponse()->setHeader('HTTP/1.1','404 Not Found');
$this->getResponse()->setHeader('Status','404 File not found');


function startsWith($haystack$needle)
    return (
substr($haystack0$length) === $needle);

//echo $path;

if (startsWith($path'/my-category/')) {
//   echo "yes";

Well its a start..!

Magento Community Magento Community
Magento Community
Magento Community
Jr. Member
Total Posts:  1
Joined:  2011-10-20
Ahmedabad, India


Magento Community Magento Community
Magento Community
Magento Community
Jr. Member
Total Posts:  15
Joined:  2011-11-08
Copenhagen, Denmark


You can also have a look at my extension, that do something like it to.

Magento Community Magento Community
Magento Community
Magento Community
Jr. Member
Total Posts:  9
Joined:  2013-12-22


If your problem is not solved, maybe you can try our extension Product redirection.

Here are some fontionnalities:

Redirect your old product page
SEO 301 redirections of product pages
You can chose to redirect to another product page, to a category, to a page, to the homepage, or another URL
Deactivated are also redirected
You can chose to automatically redirect your product if this one become disabled or out of stock

Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top