GET Bucket website

Last updated: 2019-06-14 18:50:29

Description

This API (GET Bucket website) is used to obtain the configuration of the static website associated with the Bucket.

Request

Request example

GET /?website HTTP/1.1
Host:<BucketName-APPID>.<Region>.myqcloud.com
Date:date
Authorization: Auth String

Authorization: Auth String (For more information, see Request Signature).

Request headers

Common headers

Common request headers are used for the implementation of this request operation. For more information, see Common Request Headers.

Special request headers

This request operation does not use any special request header.

Request body

The request body of this request is empty.

Response

Response headers

Common response headers

This response uses common response headers. For more information, see Common Response Headers.

Special response headers

This response does not use any special response header.

Response body

Application/xml data is returned in the response body. It contains the complete node data, as shown below:

<WebsiteConfiguration>
    <IndexDocument>
        <Suffix>index.html</Suffix>
    </IndexDocument>
    <RedirectAllRequestsTo>
        <Protocol>https</Protocol>
    </RedirectAllRequestsTo>
    <ErrorDocument>
        <Key>Error.html</Key>
    </ErrorDocument>
    <RoutingRules>
        <RoutingRule>
            <Condition>
                <HttpErrorCodeReturnedEquals>404</HttpErrorCodeReturnedEquals>
            </Condition>
            <Redirect>
                <Protocol>https</Protocol>
                <ReplaceKeyWith>404.html</ReplaceKeyWith>
            </Redirect>
        </RoutingRule>
        <RoutingRule>
            <Condition>
                <KeyPrefixEquals>docs/</KeyPrefixEquals>
            </Condition>
            <Redirect>
                <Protocol>https</Protocol>
                <ReplaceKeyPrefixWith>documents/</ReplaceKeyPrefixWith>
            </Redirect>
        </RoutingRule>
        <RoutingRule>
            <Condition>
                <KeyPrefixEquals>img/</KeyPrefixEquals>
            </Condition>
            <Redirect>
                <Protocol>https</Protocol>
                <ReplaceKeyWith>demo.jpg</ReplaceKeyWith>
            </Redirect>
        </RoutingRule>
    </RoutingRules>
</WebsiteConfiguration>

Details are described below:

Name Parent Node Description Type Required
WebsiteConfiguration None Static website configuration, including index document, error document, protocol conversion and routing rules. Container Yes
IndexDocument WebsiteConfiguration Index document Container Yes
Suffix IndexDocument Specifies the index document String Yes
ErrorDocument WebsiteConfiguration Error document Container No
Key ErrorDocument Specifies the common error page returned String No
RedirectAllRequestsTo WebsiteConfiguration Redirects all requests Container No
Protocol RedirectAllRequestsTo Specifies the routing protocol for the entire website. Only HTTP is supported. String No
RoutingRules WebsiteConfiguration Sets routing rules in batch. A maximum of 100 routing rules can be set. Container No
RoutingRule RoutingRules Sets a single routing rule. You can set a routing rule for the requests with a specified path prefix or for the requests for which a specified error code is returned. Container No
Condition RoutingRule Specifies the condition for the redirection. You cannot specify both prefix match routing condition and error code routing condition. Container No
HttpErrorCodeReturnedEquals Condition Specifies the redirection error code. Only 4XX status codes are supported. It has a higher priority than ErrorDocument. Integer No
KeyPrefixEquals Condition Specifies the prefix of the paths to be redirected. String No
Redirect RoutingRule Specifies the replacement rule when the redirection condition is met. Container No
ReplaceKeyWith Redirect Specifies the content which is used to replace the entire Key. String No
ReplaceKeyPrefixWith Redirect Specifies the content which is used to replace the prefix of Key. This is allowed only when Conditon is KeyPrefixEquals. String No

Error codes

No special error message is returned for this request operation. For common error messages, see Error Codes.

Example

Request

GET /?website HTTP/1.1
Host: examplebucket-1250000000.cos.ap-shanghai.myqcloud.com
Date:Thu, 21 Sep 2017 13:09:53 +0000
Authorization:q-sign-algorithm=sha1&q-ak=AKIDWtTCBYjM5OwLB9CAwA1Qb2ThTSUjfGFO&q-sign-time=1484815944;32557711944&q-key-time=1484815944;32557711944&q-header-list=host&q-url-param-list=website&q-signature=a2d28e1b9023d09f9277982775a4b3b705d0e23e

Response

HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: 751
Connection: keep-alive
Date: Thu, 21 Sep 2017 13:15:39 GMT
Server: tencent-cos
x-cos-request-id: NTljM2JiN2FfMjQ4OGY3MGFfNzk4OV84Mg==

<WebsiteConfiguration>
    <IndexDocument>
        <Suffix>index.html</Suffix>
    </IndexDocument>
    <RedirectAllRequestsTo>
        <Protocol>https</Protocol>
    </RedirectAllRequestsTo>
    <ErrorDocument>
        <Key>Error.html</Key>
    </ErrorDocument>
    <RoutingRules>
        <RoutingRule>
            <Condition>
                <HttpErrorCodeReturnedEquals>404</HttpErrorCodeReturnedEquals>
            </Condition>
            <Redirect>
                <Protocol>https</Protocol>
                <ReplaceKeyWith>404.html</ReplaceKeyWith>
            </Redirect>
        </RoutingRule>
        <RoutingRule>
            <Condition>
                <KeyPrefixEquals>docs/</KeyPrefixEquals>
            </Condition>
            <Redirect>
                <Protocol>https</Protocol>
                <ReplaceKeyPrefixWith>documents/</ReplaceKeyPrefixWith>
            </Redirect>
        </RoutingRule>
        <RoutingRule>
            <Condition>
                <KeyPrefixEquals>img/</KeyPrefixEquals>
            </Condition>
            <Redirect>
                <Protocol>https</Protocol>
                <ReplaceKeyWith>demo.jpg</ReplaceKeyWith>
            </Redirect>
        </RoutingRule>
    </RoutingRules>
</WebsiteConfiguration>