magento 任意页面设置robots noindex nofollow

最近不想让google爬取产品的三级页面,顺手写了个。希望对遇到同样问题的朋友提供点帮助。

首先,在配置文件中修改

    <catalog_product_view translate="label">
        <reference name="head">
            <action method="setAttribute"><name>robots</name><value>noindex,nofollow</value></action>
        </reference>
    </catalog_product_view>

想要哪个页面不抓取,只要在对应的控制的配置文件中添加reference head就可以。

接下来修改模版文件中的head.phtml,

app\design\frontend\default\default\template\page\html\head.phtml

<meta name="robots" content="<?php if($this->getData('robots')) echo $this->getData('robots');else echo htmlspecialchars($this->getRobots()) ?>" />


这样子就可以了,想noindex,nofollow哪个页面,只要在对应的模块xml中添加

        <reference name="head">
            <action method="setAttribute"><name>robots</name><value>noindex,nofollow</value></action>
        </reference>
就行了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值