- 最新
- 投票最多
- 评论最多
The default root object is configured incorrectly. According to the docs it should only be the object name relative to the bucket without any prefix /
. In your case it should be index.html
.
https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/DefaultRootObject.html
You could use a CloudFront Function to append index.html
to requests that don't specify a filename: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/example-function-add-index.html
I had a similar problem with the s3/cloud front configuration for my blog site. I had to use a custom origin in the cloudfront distribution.
If you look at https://headforthe.cloud/article/hosting-a-static-blog-in-aws/, it shares the terraform I used to deploy my site, specifically at https://headforthe.cloud/article/hosting-a-static-blog-in-aws/#cloudfront.
- Make sure that you have set up the S3 bucket to act as a static website
- Check if the "Origin Domain Name" is set to the S3 website endpoint (e.g., example-com.s3-website-us-east-1.amazonaws.com) instead of the bucket's REST endpoint (e.g., example-com.s3.us-east-1.amazonaws.com). If not, update the "Origin Domain Name" to the S3 website endpoint.
- In the CloudFront Management Console, select your distribution and click on the "Distribution Settings" tab. Under "Default Root Object," set the value to "index.html" (without the bucket URL). This setting ensures that when users request the root URL of your website, CloudFront serves the "index.html" file. and Please Check
相关内容
- AWS 官方已更新 1 年前
- AWS 官方已更新 3 年前
- AWS 官方已更新 9 个月前
- AWS 官方已更新 2 年前
It worked. I am eternally grateful.