PutBucketWebsite
更新时间 2026-04-10 20:09:07
最近更新时间: 2026-04-10 20:09:07
功能说明
PutBucketWebsite请求为存储桶进行静态网站托管或数据回源设置。
注意事项
要求使用自定义域名访问静态网站。
请求消息样式
PUT /{Bucket}?website HTTP/1.1
Host: xxx.zos.ctyun.cn
Accept-Encoding: identity
X-Amz-Date: 20220408T025144Z
X-Amz-Content-SHA256: 25bb7479fc4f8d34ec53069866ce65e1010fa7985d926d400dad59bd013d82b6
Authorization: string
Content-Length: 921
<WebsiteConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<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>
<Type>string</Type>
<HostName>string</HostName>
<HttpRedirectCode>string</HttpRedirectCode>
<Protocol>string</Protocol>
<ReplaceKeyPrefixWith>string</ReplaceKeyPrefixWith>
<ReplaceKeyWith>string</ReplaceKeyWith>
</Redirect>
</RoutingRule>
</RoutingRules>
</WebsiteConfiguration>请求消息参数
| 参数名称 | 参数描述 | 类型 | 是否必须 |
|---|---|---|---|
| Bucket | 参数解释: 桶的名称。 | String | 是 |
请求消息头
该请求使用公共的请求消息头,请参见如何调用API-构造请求-请求消息头。
请求消息元素
| 参数名称 | 参数描述 | 类型 | 是否必须 |
|---|---|---|---|
| WebsiteConfiguration | 参数解释: Website配置信息的根节点。 | Container | 是 |
表WebsiteConfiguration
| 参数名称 | 参数描述 | 类型 | 是否必须 |
|---|---|---|---|
| ErrorDocument | 参数解释: 错误文档配置。 | Container | 否 |
| IndexDocument | 参数解释: 索引文档配置。 | Container | 否 |
| RedirectAllRequestsTo | 参数解释: 重定向所有请求配置,该规则与其他规则互斥,也就是说使用了重定向规则就不能配置其他规则。 | Container | 否 |
| RoutingRules | 参数解释: 回源规则配置。 | Container | 否 |
表ErrorDocument
| 参数名称 | 参数描述 | 类型 | 是否必须 |
|---|---|---|---|
| Key | 参数解释: 指定的通用错误文档,当发生错误且未命中重定向规则中的错误码重定向时,将返回该错误文档中的内容。 | String | 否 |
表IndexDocument
| 参数名称 | 参数描述 | 类型 | 是否必须 |
|---|---|---|---|
| Suffix | 参数解释: 指定索引文档后缀。例如指定为index.html,那么当访问到存储桶的根目录时,会自动返回 index.html 的内容,或者当访问到article/目录时,会自动返回 article/index.html的内容。 | String | 否 |
表RedirectAllRequestsTo
| 参数名称 | 参数描述 | 类型 | 是否必须 |
|---|---|---|---|
| HostName | 参数解释: 要重定向的主机名。 | String | 否 |
| Protocol | 参数解释: 重定向时使用的协议。 | String | 否 |
表RoutingRules
| 参数名称 | 参数描述 | 类型 | 是否必须 |
|---|---|---|---|
| RoutingRule | 参数解释: 回源规则。 | Container | 否 |
表RoutingRule
| 参数名称 | 参数描述 | 类型 | 是否必须 |
|---|---|---|---|
| Condition | 参数解释: 回源条件。 | Container | 否 |
| Redirect | 参数解释: 回源规则,可以配置重定向回源规则或镜像回源规则。 | Container | 否 |
表Condition
| 参数名称 | 参数描述 | 类型 | 是否必须 |
|---|---|---|---|
| HttpErrorCodeReturnedEquals | 参数解释: 指定回源生效时的错误码。 | String | 否 |
| KeyPrefixEquals | 参数解释: 指定回源生效时的对象前缀。 | String | 否 |
表Redirect
| 参数名称 | 参数描述 | 类型 | 是否必须 |
|---|---|---|---|
| Type | 参数解释: 指定回源类型,可选重定向回源(REDIRECTION)或镜像回源(MIRROR)。 | String | 否 |
| HostName | 参数解释: 回源生效时回源请求的主机名。 | String | 否 |
| HttpRedirectCode | 参数解释: 回源响应中的HTTP状态码。 | String | 否 |
| Protocol | 参数解释: 回源生效时使用的协议(http或https)。 | String | 否 |
| ReplaceKeyPrefixWith | 参数解释: 回源生效时回源请求中的对象名前缀。 | String | 否 |
| ReplaceKeyWith | 参数解释: 回源生效时回源请求中的对象名。 | String | 否 |
响应消息样式
HTTP/1.1 Status Code
x-amz-request-id: tx000000000000000000002-00624fa340-3b9d5-default
Content-Type: application/xml
Content-Length: 0
Date: Fri, 08 Apr 2022 02:51:44 GMT
Connection: Keep-Alive响应消息头
该请求的响应消息使用公共的响应消息头,请参见如何调用API-响应结果-响应消息头。
响应消息元素
该请求的响应中不带有响应元素。
错误码
请参见调用前必知-错误码-全局错误码。