【问题标题】:prevent googlebot from indexing file types in robots.txt and .htaccess阻止 googlebot 索引 robots.txt 和 .htaccess 中的文件类型
【发布时间】:2016-09-15 12:12:58
【问题描述】:

有很多关于如何防止 google bot 索引的 Stack Overflow 问题,例如,txt 文件。有这个:

robots.txt

User-agent: Googlebot Disallow: /*.txt$

.htaccess

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

但是,当试图阻止两种类型的文件被索引时,这两种方法的语法是什么?在我的情况下 - txtdoc

【问题讨论】:

    标签: apache .htaccess robots.txt googlebot


    【解决方案1】:

    在您的 robots.txt 文件中:

    User-agent: Googlebot
    Disallow: /*.txt$
    Disallow: /*.doc$
    

    更多详情请访问 Google 网站管理员:Create a robots.txt file


    在您的 .htaccess 文件中:

    <FilesMatch "\.(txt|doc)$">
        Header set X-Robots-Tag "noindex, nofollow"
    </FilesMatch>
    

    更多详情:http://httpd.apache.org/docs/current/sections.html

    【讨论】:

    • 谢谢。顺便说一句,为什么我用作示例的那个说&lt;files&gt; 而你的说&lt;ifmodule- 有什么区别?我正在使用 php 服务器
    • 两者都是 Apache 指令。您可以在此处查看定义:httpd.apache.org/docs/current/sections.html
    猜你喜欢
    • 2023-02-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-03
    • 2011-06-13
    • 2019-01-03
    • 1970-01-01
    • 2012-10-22
    • 2022-01-09
    相关资源
    最近更新 更多