magento的robots文件编写和判断是否是一个导航分类页面

magento是网店系统,我们突出的是我们的产品,所以,有很多路径我们不想让搜索引擎索引到,所以我们需要用robots文件进行限制

下面是麦神magento的robots.txt里面的内容,因为很多url重写和伪静态,所以,不要复制使用,这个格式是针对麦神Magento版本的

User-agent: *
Disallow: /home/
Disallow: /catalogsearch/advanced/
Disallow: /catalog/
Disallow: /sendfriend/
Disallow: /catalogsearch/
Disallow: /checkout/
Disallow: /customer/
Disallow: /directory/
Disallow: /index/
Disallow: /newsletter/
Disallow: /developertoolbar/
Disallow: /index.php/
Disallow: /default/
Disallow: /skin/
Disallow: /*?

解释:

Magento的首页选择的是home,所以www.sample.com/home是可以访问的,但是没有任何意义,而且页面也有问题,如果被搜索引擎搜索,让客户点进来,一看有问题,立马关掉走人,影响形象,所以需要禁止

因为麦神Magento的很多动态url伪静态了,所以带有?的动态URL可以禁止索引

index.php/这种路径和url rewrite的url都是可以访问的,会造成一个页面多个url,不稳定的url很致命,所以要把这种禁止掉!

其余的不在解释,当您的网站被谷歌收录后,会发现很多页面不想被收录,那个时候,您就总结出来了,那些页面需要被禁止掉。

在magento的分类页面,当将一个页面设置成带有导航的页面的时候,我们需要判断这个页面是否是导航页面

判断是否是导航页面的方法是:

 $_category  = $this->getCurrentCategory();
    
    echo $_category->getIsAnchor();

输出为1,说明是分类侧栏带有导航的类型,如果输出为0,说明没有导航,OK!

原文地址:https://www.cnblogs.com/focai/p/4166499.html