| Did this page help you? Yes No Tell us about it... |
The following tasks guide you through using the PHP classes to manage website configuration of your bucket. For more information about the Amazon S3 website feature, see Hosting Websites on Amazon S3.
Managing Bucket Website Configuration
|
1 |
Create an instance of the |
|
2 |
To configure a bucket as a website, execute the
To retrieve existing bucket website configuration, execute
the To delete website configuration from a bucket, execute the
|
The following PHP code sample demonstrates the preceding tasks.
<?php
require_once '../aws-sdk-for-php/sdk.class.php';
header('Content-Type: text/plain; charset=utf-8');
$bucket = '*** Provide bucket name ***';
$indexDocument = '*** Provide index document name ****';
$errorDocument = '*** Provide error document name ***';
// Instantiate the class
$s3 = new AmazonS3();
// 1) Add website config. to bucket.
$response = $s3->create_website_config($bucket,
array(
'indexDocument' => $indexDocument,
'errorDocument' => $errorDocument));
// 2) Retrieve website configuration.
$response = $s3->get_website_config($bucket);
header('Content-Type: text/plain; charset=utf-8');
// 3) Delete website configuration.
$response = $s3->delete_website_config($bucket);Example
The following PHP code example first adds a website configuration to the specified
bucket. The create_website_config method explicitly provides
the index document and error document names. The sample also retrieves the website
configuration and prints the response. For more information about the Amazon S3
website feature, see Hosting Websites on Amazon S3. For instructions on how to create and test a working sample, see Using the AWS SDK for PHP.
<?php
require_once '../aws-sdk-for-php/sdk.class.php';
header('Content-Type: text/plain; charset=utf-8');
$bucket = '*** Provide bucket name ***';
$indexDocument = '*** Provide index document name ****';
$errorDocument = '*** Provide error document name ***';
// Instantiate the class
$s3 = new AmazonS3();
// 1) Add website config. to bucket.
$response = $s3->create_website_config($bucket,
array(
'indexDocument' => $indexDocument,
'errorDocument' => $errorDocument));
// Success?
var_dump($response->isOK());
// 2) Retrieve website configuration.
$response = $s3->get_website_config($bucket);
header('Content-Type: text/plain; charset=utf-8');
print_r($response);
// 3) Delete website configuration.
$response = $s3->delete_website_config($bucket);
var_dump($response->isOK());