The issue is that CloudFront doesn't automatically serve index.html for directory paths like S3 website hosting does. You need to configure CloudFront with a Lambda@Edge function or CloudFront Functions to rewrite requests from /2025/08/17/ to /2025/08/17/index.html.
Here are the solutions:
Option 1: CloudFront Functions (Recommended - Simpler & Cheaper)
Create a CloudFront Function that rewrites directory URLs:
function handler(event) {
var request = event.request;
var uri = request.uri;
// If URI ends with '/', append 'index.html'
if (uri.endsWith('/')) {
request.uri += 'index.html';
}
// If URI doesn't have an extension and doesn't end with '/', add '/index.html'
else if (!uri.includes('.')) {
request.uri += '/index.html';
}
return request;
}
Option 2: Update CloudFront Distribution Settings
- In AWS Console → CloudFront → Your Distribution
- Go to Behaviors tab
- Edit the default behavior
- Set Default Root Object to index.html (this only works for the root /)
- For subdirectories, you'll still need Option 1
Quick Fix Steps:
- CloudFront Console → Your distribution → Functions → Create function
- Runtime: CloudFront Functions
- Code: Paste the JavaScript above
- Test with URI /2025/08/17/
- Publish the function
- Associate with your distribution's Viewer Request behavior
- Deploy and wait ~5-10 minutes