阻止googlebot在robots.txt和.htaccess中索引文件类型

时间:2016-05-18 20:13:02

标签: apache .htaccess robots.txt googlebot

有很多关于如何防止谷歌机器人索引的Stack Overflow问题,例如txt个文件。就是这样:

robots.txt

User-agent: Googlebot Disallow: /*.txt$

.htaccess

<Files ~ "\.txt$">
     Header set X-Robots-Tag "noindex, nofollow"
</Files>

但是,在尝试阻止将两种类型的文件编入索引时,这两种语法的语法是什么?就我而言 - txtdoc

1 个答案:

答案 0 :(得分:3)

在您的robots.txt文件中:

User-agent: Googlebot
Disallow: /*.txt$
Disallow: /*.doc$

Google网站管理员的更多详情:Create a robots.txt file

在.htaccess文件中:

<FilesMatch "\.(txt|doc)$">
    Header set X-Robots-Tag "noindex, nofollow"
</FilesMatch>

此处有更多详情:http://httpd.apache.org/docs/current/sections.html

相关问题