- Newest
- Most votes
- Most comments
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
Relevant content
- Accepted Answerasked 8 months ago
- Accepted Answerasked a year ago
- Accepted Answerasked 2 years ago
- Accepted Answerasked 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 8 months ago
- AWS OFFICIALUpdated a year ago
It worked. I am eternally grateful.