【发布时间】:2022-09-24 20:45:25
【问题描述】:
我的示例 PDF URL 是: https://askanydifference.com/wp-content/uploads/2022/09/Difference-Between-Import-and-Export.pdf
我正在尝试对我的 wordpress 网站中的所有 PDF 文件进行无索引。在进行研究时,我了解到只能使用 .htaccess 将它们标记为 noindex 而不能使用任何其他方式,因为 pdf 文件没有任何用于元标记的 html 代码。
因此,按照下面给出的解决方案,我将 X-Robots-Tag is my .htaccess 文件添加为:
<Files \"\\.pdf$\">
Header set X-Robots-Tag \"noindex, nofollow\"
</Files>
# BEGIN WordPress
# The directives (lines) between \"BEGIN WordPress\" and \"END WordPress\" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
<IfModule mod_headers.c>
Header set Content-Security-Policy \"block-all-mixed-content\"
</IfModule>
我已将 .htaccess 文件放在 public_html 文件夹中。
但是当我在 Firefox 中的 Network 选项卡下检查文件时,X-Robots-Tag 不存在。
我所有的缓存都被禁用
关于我哪里出错的任何帮助
标签: apache .htaccess pdf search-engine