robots.txt - 防止索引包含给定字符串的图像
问题描述
我是一名摄影师,我需要防止对显示在受密码保护的商店上的客户图像进行索引(因此发现)。我可以在文件名中包含一个特定的字符串,例如 ... WWWWW ... ,它将标记我要隐藏的文件。这个 robots.txt 是否有效?
User-agent: *
Disallow: /*WWWWW*
我如何测试它是否可以?谢谢
解决方案
您可以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 。
推荐阅读
- mysql - 复合索引是否适用于加入(多对多)?
- java - 如何将计时器合并到心跳动画中?
- php - 将类公共属性传递到视图文件并使用 $this 访问它们
- c - 理解代码的问题:结构中的函数
- c# - VSCode C# 调试符号未加载
- javascript - 事件处理程序的正确名称是什么?onClick 还是 handleClick?
- linux - tex kpathsea 悬崖笔记
- firebase - 是否可以基于 Cloud-Firestore 中的字段仅获取单个文档?
- excel - 在 VBA 中创建一个简单的宏——使用单元格中的文本作为地址
- postgresql - 使用 Postgres 域来简化函数输入验证