Skip to main content

PutBucketWebsite

Sets the website configuration for a bucket. When you enable static website hosting, you can access the website using the bucket's website endpoint.

Permissions

To use this operation, you must have the PutBucketWebsite permission on the bucket. By default, only the bucket owner has this permission.

Request Headers

NameDescriptionRequiredType
Content-MD5The base64-encoded 128-bit MD5 digest of the website configuration.YesString
x-amz-expected-bucket-ownerThe account ID of the expected bucket owner.NoString

Request URI Parameters

NameDescriptionRequiredType
BucketThe bucket name.YesString

Request Body

The request must include an XML document with a WebsiteConfiguration element. The configuration includes the following elements:

NameDescriptionRequiredType
ErrorDocumentThe object key name to use when a 4XX class error occurs.NoContainer
IndexDocumentContainer for the suffix that is appended to a request that is for a directory on the website endpoint.YesContainer
RedirectAllRequestsToContainer for redirect information. You can redirect all requests to another website.NoContainer
RoutingRulesContainer for a collection of RoutingRule elements.NoContainer

Request Syntax

PUT /?website HTTP/1.1
Host: example-bucket.qstorage.quilibrium.com
Content-MD5: ContentMD5
x-amz-expected-bucket-owner: ExpectedBucketOwner

<?xml version="1.0" encoding="UTF-8"?>
<WebsiteConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<ErrorDocument>
<Key>error.html</Key>
</ErrorDocument>
<IndexDocument>
<Suffix>index.html</Suffix>
</IndexDocument>
<RedirectAllRequestsTo>
<HostName>example.com</HostName>
<Protocol>https</Protocol>
</RedirectAllRequestsTo>
<RoutingRules>
<RoutingRule>
<Condition>
<KeyPrefixEquals>docs/</KeyPrefixEquals>
</Condition>
<Redirect>
<ReplaceKeyWith>documents/</ReplaceKeyWith>
</Redirect>
</RoutingRule>
</RoutingRules>
</WebsiteConfiguration>

Response Headers

The operation returns only common response headers.

Response Body

This operation does not return a response body.

Response Errors

NameDescriptionRequiredType
InvalidArgumentInvalid argument.NoError
MalformedXMLThe XML provided was not well-formed or did not validate against the published schema.NoError

Examples

Configure a Bucket as a Static Website

The following request configures a bucket for website hosting. The configuration specifies index.html as the index document and error.html as the error document.

Sample Request

PUT /?website HTTP/1.1
Host: example-bucket.qstorage.quilibrium.com
Content-MD5: 0123456789abcdef0123456789abcdef
Date: Thu, 27 Jan 2024 12:00:00 GMT
Authorization: authorization string

<?xml version="1.0" encoding="UTF-8"?>
<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

HTTP/1.1 200 OK
x-amz-request-id: 1234567890ABCDEF
Date: Thu, 27 Jan 2024 12:00:00 GMT
Server: QStorage

API Test Component

Test

Coming Soon

This feature is currently under development and will be available soon.