最近不想让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>
就行了。