Create a bucket website configuration

A PUT operation uses the website query parameter to set the Website Configuration Policy for the bucket. An integrity check is optional for the payload. This can be done using Content-MD5, x-amz-content-sha256, or an x-amz-checksum- header.

Syntax

PUT https://{endpoint}/{bucket-name}?website # path style
PUT https://{bucket-name}.{endpoint}?website # virtual host style

Payload elements

The body of the request must contain an XML block with the following schema:
Name Type Description Children Ancestor Constraint
WebsiteConfiguration Container Root level tag for the WebsiteConfiguration parameters

IndexDocument

ErrorDocument

RedirectAllRequestsTo

RoutingRules
None Limit 1
IndexDocument String The name of the index document for the website. None WebsiteConfiguration Limit 1
ErrorDocument String The name of the error document for the website. None WebsiteConfiguration Limit 1
RedirectAllRequestsTo Container The redirect behavior for every request to the bucket’s website endpoint.

HostName

Protocol

WebsiteConfiguration Limit 1
HostName String Name of the host where requests are redirected. None RedirectAllRequestsTo  
Protocol String Protocol to use when redirecting requests. None RedirectAllRequestsTo Valid Values: http | https.
RoutingRules Container Rules that define when a redirect is applied and the redirect behavior. RoutingRule WebsiteConfiguration Limit 50
RoutingRule Container Specifies the redirect behavior and when a redirect is applied.

Condition

Redirect

RoutingRules  
Condition Container Specifies a condition that must be met for the specified redirect to apply

HttpErrorCodeReturnedEquals

KeyPrefixEquals

RoutingRule  
HttpErrorCodeReturnedEquals String The HTTP error code when the redirect is applied. In the event of an error, if the error code equals this value, then the specified redirect is applied. Required when parent element Condition is specified and sibling KeyPrefixEquals is not specified. If both are specified, then both must be true for the redirect to be applied. None

Condition

 
KeyPrefixEquals String The object key name prefix when the redirect is applied. Required when the parent element Condition is specified and sibling HttpErrorCodeReturnedEquals is not specified. If both conditions are specified, both must be true for the redirect to be applied . None Condition  
Redirect Container Container for redirect information. You can redirect requests to another host, to another page, or with another protocol. In the event of an error, you can specify a different error code to return.

HostName

HttpRedirectCode

Protocol

ReplaceKeyPrefixWith

ReplaceKeyWith

RoutingRule  
HostName String The host name to use in the redirect request. None Redirect  
HttpRedirectCode String The HTTP redirect code to use on the response. Not required if one of the siblings is present None Redirect  
Protocol String The protocol to use when redirecting requests. The default is the protocol that is used in the original request. None Redirect  
ReplaceKeyPrefixWith String The object key prefix to use in the redirect request. Not required if one of the siblings is present. Can be present only if ReplaceKeyWith is not provided None Redirect  
ReplaceKeyWith String The specific object key to use in the redirect request. Not required if one of the siblings is present. Can be present only if ReplaceKeyPrefixWith is not provided None Redirect  
<WebsiteConfiguration>
   <ErrorDocument>
      <Key>string</Key>
   </ErrorDocument>
   <IndexDocument>
      <Suffix>string</Suffix>
   </IndexDocument>
   <RedirectAllRequestsTo>
      <HostName>string</HostName>
      <Protocol>string</Protocol>
   </RedirectAllRequestsTo>
   <RoutingRules>
      <RoutingRule>
         <Condition>
            <HttpErrorCodeReturnedEquals>string</HttpErrorCodeReturnedEquals>
            <KeyPrefixEquals>string</KeyPrefixEquals>
         </Condition>
         <Redirect>
            <HostName>string</HostName>
            <HttpRedirectCode>string</HttpRedirectCode>
            <Protocol>string</Protocol>
            <ReplaceKeyPrefixWith>string</ReplaceKeyPrefixWith>
            <ReplaceKeyWith>string</ReplaceKeyWith>
         </Redirect>
      </RoutingRule>
   </RoutingRules>
</WebsiteConfiguration> 

The optional Content-MD5 header needs to be the binary representation of a base64-encoded MD5 hash. The following snippet shows one way to achieve the content for that particular header.

echo -n (XML block) | openssl dgst -md5 -binary | openssl enc -base64

Sample request

PUT /testcontainer?website HTTP/1.1
Host: 10.137.13.35
User-Agent: curl/7.64.1
Accept: */*
Date: Thu, 02 Jul 2020 15:55:42 +0000
Authorization: AWS P54EBrPQltNxWl8y0dMD:TeOdcHCl+TuDoKjkLqO/wnvMk/Q=
Content-MD5: B1Et9dQXf/EDswrbriTzbg==
Content-Length: 146 

<WebsiteConfiguration>
   <RedirectAllRequestsTo>
      <HostName>www.example.com</HostName>
    </RedirectAllRequestsTo>
</WebsiteConfiguration>

Sample response

We are completely uploaded and fine
HTTP/1.1 200 OK
Date: Thu, 02 Jul 2020 15:55:42 GMT
X-Clv-Request-Id: e40c27b1-e0af-4d3d-a854-a15cbf681dac
Server: Cleversafe/3.15.1.10
X-Clv-S3-Version: 2.5
x-amz-request-id: e40c27b1-e0af-4d3d-a854-a15cbf681dac
Content-Length: 0