- Newest
- Most votes
- Most comments
Hello.
CloudFront uses the requested URL to access your origin.
In other words, in this case, the access is "s3-domain/about/" and if this continues, "index.html" will not be loaded.
You should see that if you request "/about/index.html" it will be loaded.
https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-values-specify.html#DownloadDistValuesOriginPath
If you want CloudFront to request your content from a directory in your origin, enter the directory path, beginning with a slash (/). CloudFront appends the directory path to the value of Origin domain, for example, cf-origin.example.com/production/images. Do not add a slash (/) at the end of the path.
So, in order for "index.html" to be loaded when accessed with "/about/", you need to rewrite the URL using CloudFront Functions etc. as shown in the document you shared.
https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/example-function-add-index.html
As far as I can see from this AWS blog, it doesn't seem to have a big impact on performance.
https://aws.amazon.com/jp/blogs/aws/introducing-cloudfront-functions-run-your-code-at-the-edge-with-low-latency-at-any-scale/
Relevant content
- Accepted Answerasked 10 months ago
- Accepted Answerasked 2 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated a year ago
Alrighty.
I'm unfamiliar with Cloudfront functions. Do I just create the function, add that code in, set cache behavior to default, publish, associate it with the distribution? Seems simple, but let me know if I am misunderstanding it.
Edit: Testing it now and it works!