首页 > 解决方案 > 防止索引包含给定字符串的图像

问题描述

我是一名摄影师,我需要防止对显示在受密码保护的商店上的客户图像进行索引(因此发现)。我可以在文件名中包含一个特定的字符串,例如 ... WWWWW ... ,它将标记我要隐藏的文件。这个 robots.txt 是否有效?

User-agent: *
Disallow: /*WWWWW*

我如何测试它是否可以?谢谢

标签: robots.txt

解决方案


您可以robots.txt使用例如https://en.ryte.com/free-tools/robots-txt/甚至 Google 自己的测试仪https://support.google.com/webmasters/answer/6062598?hl来测试现有文件=zh


以下将禁止特定目录:

User-agent: *
Disallow: /path/to/images/

您还可以使用通配符*

User-agent: *
Disallow: /*.jpg         # Disallows any JPEG images
Disallow: /*/images/     # Disallows parsing of all */images/* directories

不需要尾随通配符,它​​们会被忽略。/*/path/*等于/*/path/

您不想列出要禁止的每个文件的广泛列表,因为该robots.txt文件的内容是公开的。因此,最好将目录优先于文件路径。

有关路径/通配符的示例以及它们实际匹配的内容,请参阅https://developers.google.com/search/reference/robots_txt#url-matching-based-on-path-values 。


推荐阅读