Redirect to index.html for S3 subfolder

前端 未结 6 750
庸人自扰
庸人自扰 2020-12-25 12:37

I have a domain example.com. I have a S3 bucket named example.com setup with an index.html file that works. Now I like to create two s

6条回答
  •  星月不相逢
    2020-12-25 12:47

    No need for a lambda function adding expense and complexity to your project.

    The following answer is quoted from https://stevepapa.com/

    https://stevepapa.com/my-great-new-post/ would be expected to work the same way as: https://stevepapa.com/my-great-new-post/index.html

    There’s a clever little way to get these flowing through to the Cloudfront distribution, and it involves changing the source origin from the one that Cloudfront presents to you by default.

    When selecting the origin source Cloudfront will show you a list of S3 buckets.

    Instead of setting the source from the bucket shown in the dropdown list, you’ll need to grab the static web hosting endpoint for that resource from its S3 settings page and pop it in manually.

    Using the static source for the Cloudfront distribution origin means any request to that distribution will be using the S3’s root object lookup, and your 404 responses should disappear as the references flow through.

    Important: After doing this, clear your browser cache and devalidate the items in your cloudfront distribution. Otherwise, the changes you made won't go live immediately.

提交回复
热议问题