2014-09-10 59 views
3

这里是我的robots.txt文件的内容:谷歌无视我的robots.txt

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

正如你所看到的,我明令禁止的所有机器人索引的文件夹imagesuploadadmin。问题是我的一位客户发送了从图像文件夹中删除内容的请求,因为images文件夹中的.pdf文档出现在Google搜索结果中。任何人都可以解释我在这里做错了什么,为什么谷歌索引我的文件夹?

Thx!

+2

这不是真的与编程有关,并且最好在http://webmasters.stackexchange.com/上提问。 – Sugar 2014-09-10 11:53:09

+0

即使我们应用robot.txt google也会搜索文件夹。我们需要用密码限制目录。最好将index.html文件放在所有目录中以避免列出文件。 – sugunan 2014-09-10 12:01:24

+1

问题[转贴给网站管理员](http://webmasters.stackexchange.com/q/68958/17633)。 – unor 2014-09-13 12:43:07

回答

7

报价Google Webmaster Docs

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

阻止Google抓取页面可能会降低该页面的排名或导致它随着时间的推移完全失效。它还可以 减少在 搜索结果下的文本中向用户提供的详细信息量。这是因为如果没有页面的内容,搜索引擎 的信息要少得多。

-

然而,robots.txt中屏蔽并不能保证一个页面将不会 显示在搜索结果:谷歌可能仍然决定,基于外部 信息,如导入链接,它是相关的。如果您希望 明确阻止页面被索引,则应该使用noindex机器人元标记或X-Robots-Tag HTTP标头的 。在这种情况下, 您不应该禁止robots.txt中的页面,因为必须抓取页面 才能看到和遵守标记。

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

  1. 组头PDF文件:

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

  2. 禁用目录index'ing /此文件夹的清单。

  3. 用“noindex”机器人元标记添加一个空的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] 
+0

您的评论真的很有帮助。谢谢! – MrD 2014-09-10 12:11:35

+0

如何禁止所有文件,而不仅仅是.pdfs? – MrD 2014-09-10 13:38:57

+0

我在答案中添加了两个示例。基本上它拒绝通过Apache Config文件进行目录访问。一个好方法是将文件夹黑名单(拒绝全部),然后添加例外,将您想要显示的文件(允许所有文件)列入白名单。 – 2014-09-10 13:44:57