aws-cdk-examples icon indicating copy to clipboard operation
aws-cdk-examples copied to clipboard

Static Site: GET /subdirectory should serve /subdirectory/index.html

Open btakita opened this issue 6 years ago • 3 comments
trafficstars

It does not seem like subdirectory index files are served. Instead a GET /subdirectory responds with a 403

btakita avatar Nov 07 '19 19:11 btakita

Hey @btakita,

Sorry for the delay, this was listed as a feature request (when it seems like a potential bug to me) and got passed over. A cursory look and I was unable to reproduce this.

A 403 Error strikes me as a potential permissions issue from your AWS configuration. Could you give me more reproduction steps? In particular, this example does not run out of the box and requires more information from the user.

NGL321 avatar Mar 04 '20 02:03 NGL321

It looks like the standard way to do the rewrite rule is to use lambda@edge. Problem with lambda@edge is that it's difficult to remove the functions once created. See https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-edge-delete-replicas.html

An alternative is to use CloudWatch. I have not tried it but seems easier to manage than lambda@edge. https://someguyontheinter.net/blog/serving-index-pages-from-a-non-root-location-via-cloudfront/

btakita avatar Mar 04 '20 02:03 btakita

you can also do that creating a "subdirectory" file containing HTML and adding the text/html content type on S3

of course with this solution you cannot have other files or routes inside the "subdirectory"

a simpler solution could be to have a "subdirectory.html" path

If I am not wrong, having the URL "subdirectory" serving a "subdirectory/index.html" is not a specification, it comes from Apache rewrites or similar. It is a feature we are used to, not something that "should" be.

fibo avatar Jun 23 '22 07:06 fibo

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.

github-actions[bot] avatar Dec 27 '24 21:12 github-actions[bot]