S3 static pages without .html extension

0 votes

When serving a static site off from Amazon S3, I'm wondering how to get rid of the .html file extensions for each page.

I am getting an error for 

mysite.com/mypage  
404 Not Found

Code: NoSuchKey
Message: The specified key does not exist.
Key: mypage
RequestId: 1089D7A26EFED9AD
HostId: Ud8cFy8Zl1mJ+oFjFOmU1Xacq9+v70KuaJfOc4nFMEPhd66AkLhr4Pj5u0QH6Gog




In serving a static site off of Amazon S3, I'm wondering how to get rid of the .html file extensions for each page.

Right now I have:

mysite.com/             # works fine, serves index.html
mysite.com/mypage.html  # works fine
mysite.com/mypage       # doesn't work

The error for /mypage shows:

404 Not Found

Code: NoSuchKey
Message: The specified key does not exist.
Key: mypage
RequestId: 1089D7A26EFED9AD
HostId: Ud8cFy8Zl1mJ+oFjFOmU1Xacq9+v70KuaJfOc4nFMEPhd66AkLhr4Pj5u0QH6Gog

I have tried setting the Content-Type to text/htm but it doesn't fix the problem for me.

How do I get /mypage to serve the file at /mypage.html on S3?

 

Sep 14, 2018 in AWS by datageek
• 2,430 points
114 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes
You have to set the meta data of the file Content-type to text/html AND rename the file removing the .html of the end.

That way you will be able to reach every page without the file extension.
answered Sep 14, 2018 by Archana
• 4,090 points

Related Questions In AWS

0 votes
1 answer

S3 Static Website Hosting Route All Paths to Index.html

Yes there is an easy way to ...READ MORE

answered Apr 8, 2018 in AWS by code_ninja
• 5,980 points
206 views
0 votes
1 answer

Directory Listing in S3 Static Website

There is also a solution: https://github.com/caussourd/aws-s3-bucket-listing Similar to https://github.com/rgrp/s3-bucket-listing but I couldn't ...READ MORE

answered Jul 18, 2018 in AWS by Cloud gunner
• 4,250 points
312 views
0 votes
1 answer

Hosting static website with AWS S3 and Route 53

Add an additional bucket called myblog.com and ...READ MORE

answered Dec 4, 2018 in AWS by Archana
• 5,360 points
62 views
+5 votes
3 answers
+4 votes
5 answers

Usage of Amazon Cloudfront or S3

When to use S3? S3 is like many ...READ MORE

answered Apr 3, 2018 in AWS by brat_1
• 7,080 points
72 views
+3 votes
5 answers

Renaming files in S3

You can either use AWS CLI or ...READ MORE

answered Oct 16, 2018 in AWS by petter dj
482 views
+2 votes
4 answers

S3 REST API PUT/ POST method

The POST verb is most-often utilized to ...READ MORE

answered Oct 25, 2018 in AWS by regina phillange
501 views
0 votes
1 answer

How to upload a file to Amazon S3 without passing it my server?

This article pretty much explains the entire ...READ MORE

answered Aug 14, 2018 in AWS by Archana
• 4,090 points
42 views
0 votes
1 answer

Difference between AWS S3 and Amazon Storage Gateway

Basically AWS S3 is a file system. It ...READ MORE

answered Aug 4, 2018 in AWS by Archana
• 4,090 points
83 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.