Overview
This API is used to query the configuration of static websites associated with a bucket.
Request
Sample request
GET /?website HTTP/1.1
Host: <BucketName-APPID>.cos.<Region>.myqcloud.com
Date: GMT Date
Authorization: Auth String
Request parameters
This API has no request parameter.
Request body
This API does not have a request body.
Response
Response body
A successful query will return application/xml data that includes all information about the static website configuration of the bucket.
<WebsiteConfiguration>
<IndexDocument>
<Suffix>string</Suffix>
</IndexDocument>
<RedirectAllRequestsTo>
<Protocol>string</Protocol>
</RedirectAllRequestsTo>
<ErrorDocument>
<Key>string</Key>
</ErrorDocument>
<RoutingRules>
<RoutingRule>
<Condition>
<HttpErrorCodeReturnedEquals>integer</HttpErrorCodeReturnedEquals>
</Condition>
<Redirect>
<Protocol>string</Protocol>
<ReplaceKeyWith>string</ReplaceKeyWith>
</Redirect>
</RoutingRule>
<RoutingRule>
<Condition>
<KeyPrefixEquals>string</KeyPrefixEquals>
</Condition>
<Redirect>
<Protocol>string</Protocol>
<ReplaceKeyPrefixWith>string</ReplaceKeyPrefixWith>
</Redirect>
</RoutingRule>
</RoutingRules>
</WebsiteConfiguration>
The nodes are described as follows:
|
| | Stores the result of GET Bucket website. | |
Content of WebsiteConfiguration:
|
| | Index document configuration | |
| | Redirection configuration for all requests | |
| | Error document configuration | |
| | Routing rule configuration | |
Content of IndexDocument:
|
| WebsiteConfiguration.IndexDocument | The object key suffix of index documents. For example, if this parameter is set to index.html, index.html will be automatically returned when you access the root directory of the bucket, and article/index.html will be returned when you access the article/ directory. | |
Content of RedirectAllRequestsTo:
|
| WebsiteConfiguration.RedirectAllRequestsTo | The target protocol to redirect all requests | |
Content of ErrorDocument:
|
| WebsiteConfiguration.ErrorDocument | Object key of the general error document | |
Content of RoutingRules:
|
| WebsiteConfiguration.RoutingRules | | |
Content of RoutingRules.RoutingRule:
|
| WebsiteConfiguration.RoutingRules.RoutingRule | Condition for the routing rule | |
| WebsiteConfiguration.RoutingRules.RoutingRule | Configuration of the redirection target | |
Content of RoutingRules.RoutingRule.Condition:
|
HttpErrorCodeReturnedEquals | WebsiteConfiguration.RoutingRules.RoutingRule.Condition | The error code to match the routing rule | |
| WebsiteConfiguration.RoutingRules.RoutingRule.Condition | The object key prefix to match the routing rule | |
Content of RoutingRules.RoutingRule.Redirect:
|
| WebsiteConfiguration.RoutingRules.RoutingRule.Redirect | Target protocol for the routing rule | |
| WebsiteConfiguration.RoutingRules.RoutingRule.Redirect | Target object key to replace the original object key in the request | |
| WebsiteConfiguration.RoutingRules.RoutingRule.Redirect | Target object key prefix to replace the original object key prefix that is matched in the request | |
Error codes
This API returns common error responses and error codes. For more information, please see Error Codes. Sample
Request
GET /?website HTTP/1.1
Host: examplebucket-1250000000.cos.ap-beijing.myqcloud.com
Date: Wed, 20 May 2020 09:33:49 GMT
Authorization: q-sign-algorithm=sha1&q-ak=AKID8A0fBVtYFrNm02oY1g1JQQF0c3JO****&q-sign-time=1589967229;1589974429&q-key-time=1589967229;1589974429&q-header-list=date;host&q-url-param-list=website&q-signature=50a22a30b02b59e5da4a0820d15a36805ea7****
Connection: close
Response
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: 1163
Connection: close
Date: Wed, 20 May 2020 09:33:49 GMT
Server: tencent-cos
x-cos-request-id: NWVjNGY5N2RfYTdjMjJhMDlfNjZkY18yYWUx****
<WebsiteConfiguration>
<IndexDocument>
<Suffix>index.html</Suffix>
</IndexDocument>
<RedirectAllRequestsTo>
<Protocol>https</Protocol>
</RedirectAllRequestsTo>
<ErrorDocument>
<Key>pages/error.html</Key>
</ErrorDocument>
<RoutingRules>
<RoutingRule>
<Condition>
<HttpErrorCodeReturnedEquals>403</HttpErrorCodeReturnedEquals>
</Condition>
<Redirect>
<Protocol>https</Protocol>
<ReplaceKeyWith>pages/403.html</ReplaceKeyWith>
</Redirect>
</RoutingRule>
<RoutingRule>
<Condition>
<HttpErrorCodeReturnedEquals>404</HttpErrorCodeReturnedEquals>
</Condition>
<Redirect>
<ReplaceKeyWith>pages/404.html</ReplaceKeyWith>
</Redirect>
</RoutingRule>
<RoutingRule>
<Condition>
<KeyPrefixEquals>assets/</KeyPrefixEquals>
</Condition>
<Redirect>
<ReplaceKeyWith>index.html</ReplaceKeyWith>
</Redirect>
</RoutingRule>
<RoutingRule>
<Condition>
<KeyPrefixEquals>article/</KeyPrefixEquals>
</Condition>
<Redirect>
<Protocol>https</Protocol>
<ReplaceKeyPrefixWith>archived/</ReplaceKeyPrefixWith>
</Redirect>
</RoutingRule>
</RoutingRules>
</WebsiteConfiguration>