S3 website-redirect-location not redirecting

0

Hi, I'm having some trouble getting redirects working using the x-amz-meta-website-redirect-location property of objects in an S3 bucket. The bucket is configured for static website hosting with public access enabled.

When I create an object using the API (either via the CLI or using the Javascript SDK), setting the website-redirect-location property to a valid URL, the redirect doesn't seem to work.

In the management console I can see that the x-amz-meta-website-redirect-location key is set in the object metadata correctly. When making an HTTP request I get a 200 response instead of a 301, but I do see the x-amz-website-redirect-location header in the response, it just doesn't seem to use it to generate a redirect response.

This is the style of command I've tried using the CLI:

aws s3api put-object --website-redirect-location "https://example.com/" --bucket bucket_name --key object_name

Can anyone help?

Thanks.

David B
已提问 1 个月前310 查看次数
1 回答
0
已接受的回答

Hello,

We have tested the same scenario in our lab environment where an object was uploaded to a bucket which has static website hosting enabled. While uploading, x-amz-meta-website-redirect-location header was passed. In the management console, the metadata was correctly set on the object as you have mentioned.

However, while the object was accessed using the static website endpoint, we were successfully redirected to the website endpoint provided in the x-amz-meta-website-redirect-location header.

Please note that redirection only works if you have enabled the Static Website hosting and you are accessing the objects via the Static website endpoint. If you are accessing it directly on the S3 bucket URL or S3 API the redirection will not work. So please ensure that you are accessing the object via static website endpoint.

[+] Working with object metadata - System-defined object metadata - https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingMetadata.html#SysMetadata

If you have any further queries, please feel free to reach out to AWS Support along with your specific use-case and details, and we would be happy to assist you further.

[+] Creating support cases and case management - https://docs.aws.amazon.com/awssupport/latest/user/case-management.html

AWS
支持工程师
已回答 1 个月前
  • Hi, thanks for your time. I neglected to say I was using the static website endpoint, but thanks for the clear answer. It seems in this case I need to reach out to AWS Support for more help.

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则