Amazon S3 object redirect

后端 未结 6 495
[愿得一人]
[愿得一人] 2020-12-24 05:10

Is it possible to put a redirect header on a s3-object? Like a 301 redirect.

For example:

mybucket.amazon-aws.com/myobject --> example.com/test
         


        
6条回答
  •  再見小時候
    2020-12-24 05:44

    AWSCLI lets you do this easily now (sort of)

    1. Make sure bucket is 100% public
    2. Make sure bucket is in Website Hosting mode
    3. Only refer to site using it's full URL https://.s3-website-.amazonaws.com
    4. Use the s3api call to set the redirect

      aws s3api put-object --acl public-read --website-redirect-location "http://other-location.com" --bucket foo-bucket --key somewhere/blah

    Note: You don't post any object to S3, because it will only serve a 301 and redirect Location header.

    Test with

    curl -v 2 -L https://.s3-website-.amazonaws.com/somewhere/blah

提交回复
热议问题