2

I have successfully added "reviews list" and "add review form" to the product page.

Now I just want to completely disable reviews page (http://example.com/review/...)? (so search engines won't accidentally find and crawl it, noindex and canonical aren't an option).

Thank you for help!

2
  • Disable review/product/list, correct?
    – benmarks
    Commented Jun 2, 2013 at 12:34
  • @benmarks Yep, correct. If there are some other pages related to reviews, disable them too.
    – Marvin3
    Commented Jun 2, 2013 at 12:38

2 Answers 2

6

There are several routes in the Mage_Reviews module, and you likely don't want to disable them all. Here's a list gleaned from Mage/Reviews/controllers/:

  • review/customer/(index) - customer account view of their reviews
  • review/customer/view/id/{review id} - customer account view of a single review
  • review/product/list/id/{product id}/[(category)/{category id}] - list of reviews for a product
  • review/product/post - process action for posting a review
  • review/product/view/id/{review id} - individual view for a single product review - keep?

Bold = paths which you do/might want to map & redirect, italics = paths to keep.

Whereas there is content which can and should be used for the review requests, this seems best accomplished using an observer. To catch the review/product/list route the observer should observe the controller_action_predispatch_review_product_list event in the frontend event area and set an HTTP 301 redirect to the product page. The 301 will of course be used by search engines to update links and transfer some of the link juice.

<frontend>
    <events>
        <controller_action_predispatch_review_product_list>
            <observers>
                <your_module>
                    <class>your_module/observer</class>
                    <method>redirectReviewListToProductView</method>
                </your_module>
            </observers>
        </controller_action_predispatch_review_product_list>
    </events>
</frontend>

And in your module's observer, the redirect method:

/**
 * Redirect requests for review page to product page,
 * which now contains review contents. Relies on the
 * accommodation of request object redirect in the
 * elseif condition which is present in
 * Mage_Review_ProductController::listAction().
 *
 * Observes
 * controller_action_predispatch_review_product_list
 *
 * @see Mage_Review_ProductController::listAction()
 * @see Mage_Core_Controller_Varien_Action::preDispatch()
 *
 * @param Varien_Event_Observer $observer
 */
public function redirectReviewListToProductView(Varien_Event_Observer $observer)
{
    $request = $observer->getControllerAction()->getRequest();
    /* @var $request Mage_Core_Controller_Request_Http */

    //log to custom logfile
    //Mage::log($request->getServer('HTTP_REFERER').': '.$request->getPathInfo(), Zend_Log::INFO, 'review_redirects.log',true);

    //$toUrl will be empty if missing id param or invalid product ID.
    $toUrl = Mage::getModel('catalog/product')->load($request->getParam('id'))->getProductUrl();

    //$request->_forward() is protected (no idea why), so implement noroute (404) manually.
    if (!$toUrl) {
        $request->initForward();
        $request->setActionName('noroute')->setDispatched(false);
    }
    else {
        //review/product/list accommodates redirects, so this should work
        $observer->getControllerAction()->getResponse()->setRedirect($toUrl);
        $request->setParam('id',false);
    }
}
1
  • Where does Magento even link to review/product/list/id/{product id}/[(category)/{category id}] and why dont we move the link to this uri in the template? (Then it is also not found)
    – snh_nl
    Commented Sep 10, 2020 at 8:59
0

In order to avoid problems of duplicate content, you can customize the NOINDEX robots directive for all the pages of this type : http://www.yourdomain.com/review/product/list/id/1 aby editing the file review.xml (tested magento 1.9 at least)

Here is the way to do it:

  1. Copy the file /app/design/frontend/base/default/layout/review.xml to /app/design/frontend/yourthemepath/layout/review.xml if it doesn't exist in your theme already.

  2. In this file, look for the handler <review_product_list>

  3. Under this handler, look for <reference name="head">

  4. Then simply add the line of code below between <reference name="head"> and </reference>. It will override general robots settings to NOINDEX, FOLLOW

Code to be added in the section: <action method="setRobots"><value>NOINDEX,FOLLOW</value></action>

  1. Refresh Magento cache, and look for updated NOINDEX,FOLLOW value in the source code of the page /review/product/list/id/1. It should give you something like this under <head> : <meta name="robots" content="INDEX,FOLLOW" />

  2. Google and other indexing robots will take this into account in their crawls.

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.