2014-09-10 60 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