谷歌正在忽略我的robots.txt


Google is ignoring my robots.txt

这是我的robots.txt文件的内容:

User-agent: *
Disallow: /images/
Disallow: /upload/
Disallow: /admin/

如您所见,我明确禁止所有robot对文件夹imagesuploadadmin进行索引。问题是,我的一个客户发送了从images文件夹中删除内容的请求,因为images文件夹中的.pdf文档出现在谷歌搜索结果中。有人能解释我在这里做错了什么吗?为什么谷歌为我的文件夹编制了索引?

Thx!

引用Google网站管理员文档

如果我阻止谷歌使用robots.txt抓取页面,则禁止指令,它会从搜索结果中消失吗?

阻止谷歌对页面进行爬网可能会降低该页面的排名或导致它随着时间的推移而完全退出。它也可能减少在搜索结果。这是因为如果没有页面的内容,搜索引擎要处理的信息要少得多。

--

但是,robots.txt不允许并不保证页面不会出现在结果中:谷歌仍可能根据外部诸如传入链接之类的信息。如果你愿意要显式阻止对页面进行索引,您应该使用noindex robots元标签或X-robots-tag HTTP报头。在这种情况下,您不应该禁止robots.txt中的页面,因为该页面必须为了让标签被看到并遵守,被爬行。

为文件夹中的所有文件设置带有noindex的X-Robots-Tag标头。从您的Web服务器配置中为文件夹设置此标头。https://developers.google.com/webmasters/control-crawl-index/docs/robots_meta_tag?hl=de

  1. 从Apache Config为pdf文件设置标题:

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

  2. 禁用此文件夹的目录索引。

  3. 添加一个带有"noindex"robots元标记的空index.html。

    <meta name="robots" content="noindex, nofollow" /> <meta name="googlebot" content="noindex" />

  4. 通过手动使用网站管理员工具强制删除索引页面。


评论中的问题:如何禁止文件夹中的所有文件?

// 1) Deny folder access completely
<Directory /var/www/denied_directory>
    Order allow,deny
</Directory>
// 2) inside the folder, place a .htaccess, denying access to all, except to index.html
Order allow,deny
Deny from all
<FilesMatch index'.html>
        Allow from all
</FilesMatch>
// 3) allow directory, but disallow specifc environment match
BrowserMatch "GoogleBot" go_away_badbot
BrowserMatch ^BadRobot/0.9 go_away_badbot
<Directory /deny_access_for_badbot>
order allow,deny
allow from all
deny from env=go_away_badbot
</Directory>  
// 4) or redirect bots to main page, sending http status 301
BrowserMatch Googlebot badbot=1
RewriteEngine on
RewriteCond %{ENV:badbot} =1
RewriteRule ^/$ /main/  [R=301,L]