Reputation: 21
Similar Question: Amazon S3 downloads index.html instead of serving
I am trying to upload a directory to my S3, when I upload manually I can see as static web page. But when I upload using curl, the index.html is getting downloaded.
When I curl my request curl -I https://s3-eu-west-1.amazonaws.com/bucket_name/index.html
, I can see
HTTP/1.1 200 OK
x-amz-id-2: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
x-amz-request-id: XXXXXXXXXXXXXXXX
Date: Fri, 15 Mar 2019 21:03:50 GMT
Last-Modified: Fri, 15 Mar 2019 20:53:05 GMT
ETag: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
Accept-Ranges: bytes
Content-Type: text/html
Content-Length: 48210
Server: AmazonS3
But still the index.html is downloading.
Upvotes: 1
Views: 4537
Reputation: 6612
If you click on the file on AWS S3 console and go to Properties tab details of the file, you will see Metadata section
Remove the existing "Content-Type" metadata entry and retype it as "text/html"
If you have configured your S3 as a static web site hosting, now the file will be displayed with its HTML content instead of forcing the browser to download it
Upvotes: 0
Reputation: 44701
You must configure the relevant bucket for website hosting:
Sign in to the AWS Management Console and open the Amazon S3 console at https://console.aws.amazon.com/s3/.
In the list, choose the bucket that you want to use for your hosted website.
Choose the Properties tab.
Choose Static website hosting, and then choose Use this bucket to host a website.
You are prompted to provide the index document and any optional error documents and redirection rules that are needed.
For information about what an index document is, see Configuring Index Document Support.
Upvotes: 0