GetBucketWebsite操作用於查看bucket的靜態網站託管狀態。
請求文法
GET /?website HTTP/1.1
Host: BucketName.oss-cn-hangzhou.aliyuncs.com
Date: GMT Date
Authorization: SignatureValue
響應元素(Response Elements)
名稱 | 類型 | 描述 |
---|---|---|
ErrorDocument | 容器 | 子項目Key的父元素 父元素:WebsiteConfiguration |
IndexDocument | 容器 | 子項目Suffix的父元素 父元素:WebsiteConfiguration |
Key | 字元串 | 返回404錯誤時使用的檔案名 父元素:WebsiteConfiguration.ErrorDocument 有條件:當ErrorDocument設定時,必需 |
Suffix | 字元串 | 返回目錄URL時添加的索引檔案名,不要為空,也不要包含"/"。例如索引檔案設定為index.html,則訪問:regionid.example.com/mybucket/mydir/這樣請求的時候預設都相當於訪問regionid.example.com/mybucket/index.html 父元素:WebsiteConfiguration.IndexDocument |
WebsiteConfiguration | 容器 | 請求的容器 父元素:無 |
細節分析
- 如果Bucket不存在,返回404 no content錯誤。錯誤碼:NoSuchBucket。
- 只有Bucket的擁有者才能查看Bucket的靜態網站託管狀態,否則返回403 Forbidden錯誤,錯誤碼:AccessDenied。
- 如果源Bucket未設定靜態網站託管功能,OSS會返回404錯誤,錯誤碼為:NoSuchWebsiteConfiguration。
樣本
請求樣本:
Get /?website HTTP/1.1
Host: oss-example.oss-cn-hangzhou.aliyuncs.com
Date: Thu, 13 Sep 2012 07:51:28 GMT
Authorization: OSS qn6qrr******wuk53otfjbyc: BuG4rRK+zNh******1NNHD39zXw=
已設定LOG規則的返回樣本:
HTTP/1.1 200
x-oss-request-id: 534B371674E88A4D8906008B
Date: Thu, 13 Sep 2012 07:51:28 GMT
Connection: keep-alive
Content-Length: 218
Server: AliyunOSS
<?xml version="1.0" encoding="UTF-8"?>
<WebsiteConfiguration xmlns=”http://doc.oss-cn-hangzhou.aliyuncs.com”>
<IndexDocument>
<Suffix>index.html</Suffix>
</IndexDocument>
<ErrorDocument>
<Key>error.html</Key>
</ErrorDocument>
</WebsiteConfiguration>
未設定LOG規則的返回樣本
HTTP/1.1 404
x-oss-request-id: 534B371674E88A4D8906008B
Date: Thu, 13 Sep 2012 07:56:46 GMT
Connection: keep-alive
Content-Length: 308
Server: AliyunOSS
<?xml version="1.0" encoding="UTF-8"?>
<Error xmlns=”http://doc.oss-cn-hangzhou.aliyuncs.com”>
<Code>NoSuchWebsiteConfiguration</Code>
<Message>The specified bucket does not have a website configuration.</Message>
<BucketName>oss-example</BucketName>
<RequestId>505191BEC4689A033D00236F</RequestId>
<HostId>oss-example.oss-cn-hangzhou.aliyuncs.com</HostId>
</Error>