谷歌忽略了我的robots.txt

时间:2014-09-10 11:51:53

标签: php seo robots.txt google-search

以下是我的robots.txt文件的内容:

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

如您所见,我明确禁止所有机器人为文件夹imagesuploadadmin编制索引。问题是我的一个客户发送了从images文件夹中删除内容的请求,因为来自images文件夹的.pdf文档出现在Google搜索结果中。任何人都可以向我解释我在这里做错了什么,为什么谷歌索引我的文件夹?

THX!

1 个答案:

答案 0 :(得分:7)

引用Google Webmaster Docs

  

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

     

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

-

  

但是,robots.txt Disallow不保证页面不会   出现在结果中:Google可能仍会根据外部决定   传入链接等相关信息。如果你希望   要显式阻止页面被索引,您应该使用   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. 使用&#34; noindex&#34;添加一个空的index.html;机器人元标记。

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

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


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

    // 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]