Static Website
In this article:
Static Website#
The object storage can be used to host static websites.
PutBucketWebsite#
Specifies the bucket configuration for static website hosting.
Sample Request#
Enables website mode and sets the index page and error page.
Request
PUT /bucket1/?website=null HTTP/1.1
Host: s3.k2.cloud
X-Amz-Content-Sha256: beaead3198f7da1e70d03ab969765e0821b24fc913697e929e726aeaebf0eba3
X-Amz-Date: 20220602T082024Z
Authorization: AWS4-HMAC-SHA256 Credential=project:user@company/20220602/{region}/s3/aws4_request, SignedHeaders=host;x-amz-content-sha256;x-amz-date, Signature=e4a7e3efa4b9fa70d09eca02a06541821e3148c6982ccc11f6e5aa94b118a249
Content-Type: text/plain
Content-Length: 253
<WebsiteConfiguration xmlns='http://s3.amazonaws.com/doc/2006-03-01/'>
<IndexDocument>
<Suffix>index.html</Suffix>
</IndexDocument>
<ErrorDocument>
<Key>Error.html</Key>
</ErrorDocument>
</WebsiteConfiguration>
Sample Response#
Response
HTTP/1.1 200 OK
x-amz-request-id: tx000000000000000e65d88-006298a885-4171fb55-default
content-length: 0
date: Wed, Thu, 02 Jun 2022 12:09:41 GMT
GetBucketWebsite#
Returns the bucket configuration for static website hosting.
Sample Request#
Request
GET /bucket1?website=null HTTP/1.1
Host: s3.k2.cloud
X-Amz-Content-Sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
X-Amz-Date: 20220602T121046Z
Authorization: AWS4-HMAC-SHA256 Credential=project:user@company/20220602/{region}/s3/aws4_request, SignedHeaders=host;x-amz-content-sha256;x-amz-date, Signature=e884f4cb25a8d520e7b37b98555a733972c69140dffd63ef75a9778a2b06091e
Sample Response#
The bucket is configured to redirect HTTP requests to the example.com website.
Response
HTTP/1.1 200 OK
x-amz-request-id: tx000000000000009a2ce72-006298a8c6-37d64f12-default
content-type: application/xml
content-length: 235
date: Thu, 02 Jun 2022 12:10:46 GMT
<?xml version="1.0" encoding="UTF-8"?>
<WebsiteConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<RedirectAllRequestsTo>
<HostName>example.com</HostName>
<Protocol>http</Protocol>
</RedirectAllRequestsTo>
</WebsiteConfiguration>
DeleteBucketWebsite#
Deletes the bucket configuration for static website hosting.
Sample Request#
Request
DELETE /bucket1/?website=null HTTP/1.1
Host: s3.k2.cloud
X-Amz-Content-Sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
X-Amz-Date: 20220602T122151Z
Authorization: AWS4-HMAC-SHA256 Credential=project:user@company/20220602/{region}/s3/aws4_request, SignedHeaders=host;x-amz-content-sha256;x-amz-date, Signature=9283206df23379cc11251a62390b29b60ab3822831f2f750f4ab0a4e89003a6f
Sample Response#
Response
HTTP/1.1 204 No Content
x-amz-request-id: tx0000000000000099e53b9-006298ab5f-4017b271-default
content-length: 0
date: Wed, 01 Jun 2022 15:55:57 GMT