0

I have CloudFront distributing a static website. the way it is now example.com leads to index.html. to go to any other page I need to use the .html extension (example.com/contact.html). is there a way to have example.com/contact lead to contact.html which would allow me to get rid of the .html extension in the URL

I tried to see if I can do it in both origins and behavior but haven't found a way.

askrill
  • 33
  • 6

1 Answers1

0

If you enabled "Static Website Hosting" on your S3 bucket, uri that encounter folders with a index.html files, the index.html file will be served. For example, instead example.com/contact.html -> example.com/contact/index.html should do the trick.

  1. Make sure you enable "Static Website Hosting" for you S3 bucket. When enabling it you should get a access url - save it for (2). https://docs.aws.amazon.com/AmazonS3/latest/userguide/WebsiteHosting.html

  2. Make sure your CloudFront distribution origin points to the S3 static website url - you shuold copy/paste it from the S3 static website configuration and NOT selecting the bucket from the drop down list when creating or updating the origin.

alonn24
  • 238
  • 2
  • 15
  • Hey, is there a way to point to an object instead of a folder? for example having example.com/contact -> example.com/contact.html. I know you can achieve that through getting rid of the extension and then adding HTML into the metadata but I also would wanna do this for dynamic URLs where for example example.com/list/item1 and example.com/list/item2-> example.com/list.html then have js in the browser reach out to an API. – askrill Apr 06 '22 at 20:21