[英]Cloudfront with 2 origins (different buckets) and both host root of bucket
I have a CDN and 2 buckets我有一个 CDN 和 2 个存储桶
one bucket is using the default behaviour so img.png
is accessible via CDN URL: cdn.com/img.png
一个桶使用默认行为,以便
img.png
是通过CDN URL访问: cdn.com/img.png
one bucket is using the /path
behaviour so everything in the CDN routed to /path should go to this bucket.一个存储桶正在使用
/path
行为,因此路由到 /path 的 CDN 中的所有内容都应转到此存储桶。 It works when i put this in the bucket: path/test.png
.当我将它放入存储桶时它会起作用:
path/test.png
。 I can visit cdn.com/path/test.png
.我可以访问
cdn.com/path/test.png
。
What I want is to put test.png
in the root of my bucket without the prefix of path/
.我想要的是将
test.png
放在我的存储桶的根目录中,而没有path/
的前缀。 Is this possible (without the use of lambda@edge)?这可能吗(不使用 lambda@edge)?
If you want to rewrite the path, you have to use lambda@edge.如果要重写路径,则必须使用 lambda@edge。
If you are ok with 301 redirection, you can try enabling static website hosting on S3 bucket and use the following redirection rule :如果您对 301 重定向没问题,您可以尝试在 S3 存储桶上启用静态网站托管并使用以下重定向规则:
<RoutingRules>
<RoutingRule>
<Condition>
<KeyPrefixEquals>path/</KeyPrefixEquals>
</Condition>
<Redirect>
<ReplaceKeyPrefixWith/>
</Redirect>
</RoutingRule>
</RoutingRules>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.