• Object Storage Service

obs
  1. Help Center
  2. Object Storage Service
  3. API Reference (OBS)
  4. Operations on Buckets
  5. PUT Bucket website
  6. Examples

Examples

Example 1: Setting Website to Redirect All Requests

PUT /?website HTTP/1.1 
 User-Agent: curl/7.29.0
 Host: bucketname.obs.example.com
 Accept: */*
 Date: Sat, 04 Jan 2014 06:22:20 +0000 
 Authorization: AWS C6630CD15B645CB8A3BA:NiQpK7VHqCx93B8k14LJMSZy8ng=
 Content-Length: 198 
 Expect: 100-continue

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

Example 2: Setting Website to Add Routing Rules that Redirect Requests

PUT /?website HTTP/1.1 
 User-Agent: curl/7.29.0
 Host: bucketname.obs.example.com
 Accept: */*
 Date: Sat, 04 Jan 2014 06:22:20 +0000 
 Authorization: AWS C6630CD15B645CB8A3BA:NiQpK7VHqCx93B8k14LJMSZy8ng=
 Content-Length: 490 
 Expect: 100-continue

<WebsiteConfiguration> 
   <IndexDocument> 
     <Suffix>index.html</Suffix> 
   </IndexDocument> 
   <ErrorDocument> 
     <Key>Error.html</Key> 
   </ErrorDocument> 
   <RoutingRules> 
     <RoutingRule> 
       <Condition> 
         <KeyPrefixEquals>docs/</KeyPrefixEquals> 
       </Condition> 
       <Redirect> 
         <ReplaceKeyPrefixWith>documents/</ReplaceKeyPrefixWith> 
       </Redirect> 
     </RoutingRule> 
   </RoutingRules> 
 </WebsiteConfiguration>

Sample Response

HTTP/1.1 200 OK 
 Date: Sat, 04 Jan 2014 06:24:31 GMT 
 Server: OBS 
 x-amz-request-id: 90E2BA0A420C00000140ED7A369007A2 
 x-amz-id-2: t35S98JCFKUMswCPZCk+UTi/VOoiSenzi5J6wnoKCIMfXUsKYGgU5+daiWAYiY/8 
 x-reserved: amazon, aws and amazon web services are trademarks or registered trademarks of Amazon Technologies, Inc 
 Content-Type: text/xml 
 Content-Length: 0