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,540 points
2,915 views

1 answer to this question.

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,170 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
• 6,300 points
3,425 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,670 points
6,312 views
+2 votes
3 answers

AWS S3 - Listing all objects inside a folder without the prefix

For Scala developers, here it is recursive ...READ MORE

answered Sep 20, 2018 in AWS by Priyaj
• 58,020 points
48,837 views
+1 vote
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,640 points
1,088 views
+6 votes
3 answers
0 votes
1 answer
0 votes
1 answer

How to get the number of pages in a pdf file present in s3?

Hi@Manav, To know about information about pdf file, ...READ MORE

answered May 3, 2020 in AWS by MD
• 95,460 points
3,175 views
0 votes
1 answer

Upload to S3 using multer without a middleware function

Use multer-s3-transform middleware to handle S3 upload ...READ MORE

answered Feb 24, 2022 in AWS by Korak
• 5,820 points
3,314 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,170 points
3,247 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,170 points
7,194 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP