I want to noindex,nofollow only those product urls in which category is coming in url.

For example : I have product abc.html and it is assigned to 2 categories so it can open by three ways.

1. category1/abc.html

2. category2/abc.html

3. abc.html

I want to set noindex,nofollow for only above 1 and 2 point.Means if a product contains with category url.

1 Answer 1


Just go to the system configuration and change "Include category in product Urls" to "No", also enable the product canonical. This should have the same effect.

If you really want to change the robots, you will have to write a module. Set an observer to controller_action_layout_generate_blocks_after and include your logic into the observer function, much like this:

    $head = Mage::app()->getLayout()->getBlock('head');
    if ($head && Mage::registry('current_product') && Mage::registry('current_category')) {
  • The above code will do noindex,nofollow to both urls with category and without category. Commented Feb 19, 2019 at 11:01
  • Sorry, was only a fast answer without testing; you should adjust the condition then to check if the URL contains multiple slashes, or the URL-key of a category - depending on your store data. Commented Feb 19, 2019 at 11:03

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.