2

I'm hosting my static website on AWS S3, with Cloudfront as a CDN, and I'm wondering how I can get clean URLs working.

I currently have to go to example.com/about.html to get the about page. I'd prefer example.com/about as well as across all my other pages. Also, I kind of have to do this because my canonical URLs have been set with meta tags and search engines, and it's gonna be a bit much to go changing them.

Is there a setting in Cloudfront that I'm non seeing?

Updates

There are two options I've explored.

First is trimming .html off the file before uploading to S3 and then editing the Content Header in the http for that file. This might work beautifully, but I can't figure out how to edit content headers from the command line, where I'm writing my "push website update" bash script.

The second approach leverages S3's feature that recognizes root default files, usually index.html. Might be a great approach, but it really messes with my directory structure, and it leaves a trailing slash on the URLs which doesn't work for me.

Lambda@Edge?

Could I write a lambda function to handle this?

Update II

I'm using essentially this bash script to sync up new files

aws s3 sync site/ s3://example.com
Costa Michailidis
  • 235
  • 1
  • 2
  • 9
  • *I can't figure out how to edit content headers from the command line* ...should be easy enough. What are you using to power this script? The AWS CLI? – Michael - sqlbot Mar 21 '17 at 23:42
  • Yes, the AWS CLI. It's 'content-type' that would be useful to edit. Updated the question, and dug into the help files, --content-type is right there, staring me in the face : ) – Costa Michailidis Mar 21 '17 at 23:43
  • Duplicate of http://stackoverflow.com/questions/42741839/how-to-get-clean-urls-on-aws-cloudfront-s3 – Matt Houser Mar 22 '17 at 02:02
  • Yes, it's a duplicate, I should have put it here first off. It's more a server concern, than a coding one. – Costa Michailidis Mar 22 '17 at 02:46

0 Answers0