網(wǎng)站建設(shè)中如何禁止百度收錄,robots.txt使用詳解
robots.txt是一個純文本協(xié)議文件,用于指導(dǎo)搜索引擎爬蟲的抓取行為,是指網(wǎng)站可建立一個robots.txt文件來告訴搜索引擎哪些頁面可以抓取,哪些頁面不能抓取,而搜索引擎則通過讀取robots.txt文件來識別這個頁面是否允許被抓取。以下是一些常見的robots.txt示例:

允許所有搜索引擎抓?。?/strong>
User - agent: *
Allow: /或者直接創(chuàng)建一個空的robots.txt文件放在網(wǎng)站根目錄下,也表示允許所有搜索引擎訪問網(wǎng)站的所有部分。
禁止所有搜索引擎抓?。?/strong>
User - agent: *
Disallow: /禁止特定搜索引擎抓取:例如禁止百度蜘蛛抓取,可寫成:
User - agent: Baiduspider
Disallow: /允許特定搜索引擎抓?。?/strong>例如只允許搜狗抓取:
User - agent: Sogou web spider
Disallow:拒絕所有搜索引擎抓取指定目錄:
User - agent: *
Disallow: /admin/
Disallow: /tmp/
Disallow: /abc/禁止 admin 目錄,但允許抓取 admin 目錄下的 seo 子目錄:
User - agent: *
Allow: /admin/seo/
Disallow: /admin/禁止抓取 /abc/ 目錄下的所有以 ".htm” 為后綴的 URL(包含子目錄):
User - agent: *
Disallow: /abc/*.htm$禁止抓取網(wǎng)站中所有的動態(tài)頁面:
User - agent: *
Disallow: /?禁止百度蜘蛛抓取網(wǎng)站所有的圖片:
User - agent: Baiduspider
Disallow: /.*jpg$
Disallow: /.*jpeg$
Disallow: /.*gif$
Disallow: /.*png$指定網(wǎng)站地圖位置:
User - agent: *
Disallow: /private/
Disallow: /temp/
Allow: /temp/public
Sitemap: http://www.example.com/sitemap.xml這個例子中,禁止所有搜索引擎爬蟲訪問/private/目錄和/temp/目錄下的大部分內(nèi)容,但允許訪問/temp/public,同時指定了網(wǎng)站地圖的位置。