Why isn't CloudFront returning my default root object from a subdirectory?

1 minute read
0

I want to know why Amazon CloudFront doesn't return my default root object from a subfolder or subdirectory.

Resolution

The CloudFront default root object feature supports only the root of the origin that your distribution points to.

CloudFront doesn't return default root objects in subdirectories. For more information, see Specifying a default root object.

If your CloudFront distribution must return the default root object from a subfolder or subdirectory, then you can integrate Lambda@Edge with your distribution. For an example configuration, see Implementing default directory indexes in Amazon S3 backed Amazon CloudFront origins using Lambda@Edge.

Important: You are charged an additional fee when you use Lambda@Edge. For more information, see AWS Lambda pricing.

Related information

Configuring an index document

AWS OFFICIAL
AWS OFFICIALUpdated a year ago
1 Comment

I was in the same situation that I wanted CloudFront to return an object in a directory under a bucket and I found a simpler way to do that eventually. Let me share it here.

Another Resolution

You can set both Origin Path mentioning a directory including the object you want to get in a bucket and Default Root Object referring the object itself. This worked well for my case. Give it a try.

oratosa
replied a month ago