使用htaccess防止PDF文件建立索引

问题描述 投票:0回答:1

我的网站上不同文件夹中都有大量PDF文件。我需要防止它们使用.htaccess被Google索引(因为robots.txt显然不会阻止其他页面链接到文件的索引)。

但是,我尝试将以下内容添加到我的.htaccess文件中:

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

无济于事;即使我要求Google重新索引该网站,但在搜索“ site:mysite.com pdf”时,PDF文件仍会显示。

我无法选择在其他位置托管文件或使用登录系统保护文件;我真的很想简单地获取htaccess文件来完成这项工作。我想念什么?

.htaccess pdf googlebot
1个回答
0
投票

只需将此粘贴到您的htaccess文件中,请使用set而不是append

<Files ~ "\.pdf$">
Header set X-Robots-Tag "noindex, nofollow"
</Files>
© www.soinside.com 2019 - 2024. All rights reserved.