0

I have a few problems with indexed pages, therefore i want to no-index a few url's with problems.

/brand/index/ /nieuw/

So these 2 url's and also all other url's below, for example /brand/index/color/... and /nieuw/brand/...

Who can help me and have a solution?

0

Method 1: In the backend when editing a product/category/cms go to the tab design and add the following to custom layout:

 <reference name="head">
        <action method="setRobots"><meta>NOINDEX,NOFOLLOW</meta></action>
  </reference>

Method 2: You can also set it by using observer using this event controller_action_layout_generate_blocks_after like this:

public function setRobots($observer) 
{
     $controller = $observer->getAction();
     $fullActionName = $controller->getFullActionName();
     if ($fullActionName == 'catalog_product_view') { //if on product page
          $product = Mage::registry('product'); //access the current product if needed
          if (your condition here) { //condition to set the robots to noindex, nofollow
              $observer->getLayout()->getBlock('head')->setRobots('NOINDEX,NOFOLLOW');
          }
     }
}

Method 3: IF you are using custom modlue then it can be added through your controller action like:

 <?php
    class Arunendra_Athletes_IndexController extends Mage_Core_Controller_Front_Action{
        public function IndexAction() {

            $this->loadLayout();    
            // change robotos with yours 
            $this->getLayout()->getBlock("head")->setRobots('NOINDEX,NOFOLLOW');
          $this->renderLayout(); 

        }
    }

Note: Change the robots with yours

|improve this answer|||||
  • Thanks for your help! But can it also be fixed by adding the next lines to robots.txt? Disallow: /administrator/ Disallow: /404/ Disallow: /index.php Disallow: /index.html Disallow: /brand/index/* Disallow: /nieuw/* – Maikel May 15 '16 at 8:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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