简体   繁体   English

AWS S3 Redirect仅适用于作为子域的存储桶,不适用于作为目录的存储桶

[英]AWS S3 Redirect only works on bucket as a subdomain not bucket as a directory

Many people have received 100s of links to PoCs that are on an internal facing bucket and the links are in this structure. 许多人已经收到了数百个指向PoC的链接,这些链接位于内部存储桶中,并且链接处于此结构中。

https://s3.amazonaws.com/bucket_name/ https://s3.amazonaws.com/bucket_name/

I added a redirect using AWS's Static website hosting section in Properties and it ONLY redirects when the domain is formatted like this: 我在“属性”中使用AWS的“静态网站托管”部分添加了重定向,并且仅在域格式如下时重定向:

https://bucket_name.s3-website-us-east-1.amazonaws.com https://bucket_name.s3-website-us-east-1.amazonaws.com

Is this a bug with S3? 这是S3的错误吗?

For now, how do I make it redirect using both types of links? 现在,如何使用两种链接进行重定向? My current workaround is to add a meta redirect tag in each html file. 我当前的解决方法是在每个html文件中添加一个meta重定向标签。

The s3-website is the only endpoint that supports redirects unfortunately. 不幸的是,s3网站是唯一支持重定向的端点。 Using the s3.amazonaws.com supposes that you will be using S3 as a storage layer, instead of a website. 使用s3.amazonaws.com假定您将使用S3作为存储层而不是网站。 If the link is to a specific object, you can place an HTML file at that url with a JS redirect, but other than that there is really no way to achieve what you are trying to do. 如果链接指向特定对象,则可以使用JS重定向将HTML文件放置在该URL上,但是除此之外,实际上没有任何方法可以实现您要执行的操作。

In the future, i would recommend always setting up a Cloudfront distribution for those kinds of usecases, as that will allow you to change the origin later on. 将来,我建议始终为这些用例设置一个Cloudfront发行版,因为这将使您以后可以更改来源。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM