我有一个网站 www.example.com
。因此,当我访问像 www.example.com/robots.txt
这样的 robots.txt 文件时,它会显示由 SEO 团队创建/准备的多行文本。
所以有一个指向 CloudFront 的子域 assets.example.com
。当我通过像 https://assets.example.com/robtos.txt
这样的 CloudFront URL 访问 robots.txt 文件时,它会在浏览器中显示以下结果。
User-agent: *
Disallow: /
所以有一个更新 AWS CloudFront 中的 robots.txt 文件内容的请求 https://assets.example.com/robtos.txt
& https://www. example.com/robtos.txt
应该显示相同的文本。我没有找到 robots.txt 放在云端的任何地方。
是否可以在云端更新 robots.txt?这里有CloudFront的作用吗?或者我们需要更新 assets.example.com 的 robots.txt 与为 example.com 配置的一样?
请帮帮我。我在这里很困惑。
最佳答案
您可以指向 CloudFront 分配 (assets.example.com),然后使用域名 www.example.com
添加新来源,然后添加具有路径模式的新缓存行为 robots.txt
并将原点添加到其中。
此设置接受对 assets.example.com/robots.txt
的请求并将其转发到 www.example.com/robots.txt
。有了这个,您可以删除重复项。
关于amazon-web-services - 如何更新/替换 aws cloudfront 中的 robots.txt 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63578181/