SEO优化之robots的优化
1、概述
①robots.txt纯文本文件,网站管理员可以在这里声明该网站不想robots访问的部分,所以robots优化直接影响着搜索引擎对网站的收录情况;
②robots.txt必须放置在一个站点的根目录下,并且文件名必须全部小写:www.baidu.com/robots.txt;
③就算你的网站全部内容都可以被搜索引擎收录,那也要写个空的robots.txt;因为有的服务器的设置会使没有robots.txt的时候返回200状态码和相应的错误信息;
2、robots的写法
# robots.txt file from www.chuye22.com
# All robots will spider the domain
User-agent:*
Disallow:
①允许搜索引擎访问所有部分
User-agent:*
Disallow:
②禁止搜索引擎访问任何部分
User-agent:*
Disallow:/
③禁止搜索引擎访问某几个部分
User-agent:*
Disallow:www.chuye22.com/123.html
Disallow:www.chuye22.com/456.html
Disallow:www.chuye22.com/789.html
④允许某个搜索引擎访问
User-agent:Baiduspiter
Disallow:/
⑤禁止所有浏览器访问某几个目录下的内容及文件
User-agent:*
Disallow:/sss/
Disallow:/aaa/
⑥禁止除了百度浏览器以外的所有搜索引擎抓取任何内容:
User-agent:Baiduspiter
Disallow:/
User-agent:*
Disallow:/
⑦$:通配符,匹配url结尾的字符。禁止百度抓取所有.jpg文件
User-agent:Baiduspiter
Disallow:.jpg$