robots.txt 實用規則
以下是 robots.txt 一些常見的實用規則:
| 實用規則 | |
|---|---|
| 禁止檢索整個網站 |
提醒您,在某些情況下,未經檢索的網站網址仍可能會編入索引。 User-agent: * Disallow: / |
| 禁止檢索特定目錄及其中內容 |
在目錄名稱後方附加正斜線,即可禁止檢索整個目錄。 User-agent: * Disallow: /calendar/ Disallow: /junk/ Disallow: /books/fiction/contemporary/ |
| 允許單一檢索器存取網站內容 |
只有 User-agent: Googlebot-news Allow: / User-agent: * Disallow: / |
| 允許所有檢索器存取網站內容,但某一個檢索器除外 |
User-agent: Unnecessarybot Disallow: / User-agent: * Allow: / |
|
禁止檢索單一網頁 |
例如,禁止檢索位於 User-agent: * Disallow: /useless_file.html Disallow: /junk/other_useless_file.html |
|
禁止檢索整個網站,但子目錄除外 |
檢索器只能存取 User-agent: * Disallow: / Allow: /public/ |
|
禁止 Google 圖片檢索特定圖片 |
例如,禁止 User-agent: Googlebot-Image Disallow: /images/dogs.jpg |
|
禁止 Google 圖片檢索您網站上的所有圖片 |
Google 不得為未經檢索的圖片和影片建立索引。 User-agent: Googlebot-Image Disallow: / |
|
禁止檢索特定類型的檔案 |
例如,禁止檢索所有的 User-agent: Googlebot Disallow: /*.gif$ |
|
禁止檢索整個網站,但允許 |
這麼做會讓您的網頁無法顯示在搜尋結果中,但 User-agent: * Disallow: / User-agent: Mediapartners-Google Allow: / |
使用 * 和 $ 萬用字元來比對結尾為特定字串的網址 |
例如,封鎖所有 User-agent: Googlebot Disallow: /*.xls$ |