Reputation: 11
I have a static gatsby site hosted on AWS S3 and Cloudfront and I'm trying to redirect all instances of index.html to the root url "/". I tried doing this with gatsby createRedirect from "/index.html" to "/" along w AWS S3 routing rules, but it's not working as expected. The redirecting tool I use (http://www.redirect-checker.org/) notices there's a redirect, but the redirect it finds is from mysite.com/index.html to mysite.com/index.html, but I set up the rules from "/index.html" to "/". Is there a way to fix this so the response is still a 301 redirect, but to the root url instead of index.html?
Upvotes: 1
Views: 1467
Reputation: 19
You can achieve this by looking at your settings in CloudFront when creating your distribution. You'll see a setting 'Default Root Object'.
The object that you want CloudFront to return (for example, index.html) when a viewer request points to your root URL (http://www.example.com) instead of to a specific object in your distribution (http://www.example.com/index.html).
https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/DefaultRootObject.html
Upvotes: 1