How do I redirect from an Amazon S3 file to my website?

Viewed 235

enter image description here

I have a downloadable something.pkg file hosted in an Amazon S3 bucket (https://myassets.s3.amazonaws.com/something.pkg)

many people have this link but I don't want people anymore to be able to download it anymore but to be redirected to my_website.com/file_landing_page/

trying to edit the metadata of the file (as seen in the photo), setting the key x-amz-website-redirect-location to my new location does not do anything.

how can I redirect the object from the s3 console please?

1 Answers

In order to achieve redirection from an S3 object, the bucket has to be configured for static website hosting. You can check here https://docs.aws.amazon.com/AmazonS3/latest/userguide/how-to-page-redirect.html

After that setting x-amz-website-redirect-location property to the object metadata is going to work, but only from the s3 website endpoint (https://docs.aws.amazon.com/AmazonS3/latest/userguide/WebsiteEndpoints.html):

  1. s3-website dash (-) Regionhttp://bucket-name.s3-website-Region.amazonaws.com

  2. s3-website dot (.) Regionhttp://bucket-name.s3-website.Region.amazonaws.com

Unfortunately in your case even if you configure the bucket to be static your users are still using the https://myassets.s3.amazonaws.com/something.pkg which is not going to redirect.

Related