【问题标题】:robots.txt pattern matching not workingrobots.txt 模式匹配不起作用
【发布时间】:2012-07-15 08:51:04
【问题描述】:

我需要一个模式匹配规则来得到这个结果。

allow /dir/path_name.htm/something
disallow /dir/path_name/something
and disallow /dir/path_name.htm

其实这两个不允许是一直以来积累的错别字。这些页面永远不存在。如何阻止谷歌不再抓取它们?

我在这里进行了测试:http://www.frobee.com/robots-txt-check/ 使用以下内容,但似乎没有任何效果。

Allow: /dir/*.htm/?*
Disallow: /dir/*

出了什么问题?谢谢。

【问题讨论】:

    标签: php .htaccess robots.txt


    【解决方案1】:

    根据规范:

    http://www.robotstxt.org/norobots-rfc.txt

    不允许使用通配符 (*)。路径只是完全匹配。我的猜测是您正在使用某种形式的重写,并且您不希望显示具有相同内容的多个 ulr。在这种情况下,这可能是一个更好的解决方案:

    http://googlewebmastercentral.blogspot.de/2009/02/specify-your-canonical.html

    【讨论】:

    • 实际上那里也不需要通配符,因为Disallow: /path/to/dir/ 意味着忽略整个文件夹的内容,只处理这个特定的uri...
    • 如果您阅读此问题,他希望禁止子目录,但允许其中的一些 url。
    • 好吧,如果他使用Disallow: /dir/path_name.htm,我认为它不会阻止文件夹(因为它没有尾部斜杠),但是我再一次没有尝试过,所以我可能错了
    猜你喜欢
    • 2013-07-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多