Enables and configures an Amazon S3 website using the corresponding bucket as the content source.
The website will have one default domain name associated with it, which is the bucket name. If you
attempt to configure an Amazon S3 website for a bucket whose name is not compatible with DNS,
Amazon S3 returns an InvalidBucketName
error. For more information on bucket names and DNS,
refer to Bucket Restrictions and Limitations.
To visit the bucket as a website a new endpoint is created in the following pattern:
http://<bucketName>.s3-website-<region>.amazonaws.com
. This is a sample URL
for a bucket called example-bucket
in the us-east-1
region.
(e.g., http://example-bucket.s3-website-us-east-1.amazonaws.com
)
Access
public
Parameters
Parameter |
Type |
Required |
Description |
---|---|---|---|
|
Required |
The name of the bucket to use. |
|
|
Optional |
An associative array of parameters that can have the following keys:
|
Returns
Type |
Description |
---|---|
A |
Examples
Create a new website configuration.
// Instantiate the class $s3 = new AmazonS3(); $bucket = 'my-bucket' . strtolower($s3->key); // Create a website, using index.html as the root document and error.html as the error document. $response = $s3->create_website_config($bucket); // Success? var_dump($response->isOK());Result:
bool(true)
Create a new website configuration.
// Instantiate the class $s3 = new AmazonS3(); $bucket = 'my-bucket' . strtolower($s3->key); // Create a website, using home.html as the root document and 404.html as the error document. $response = $s3->create_website_config($bucket, array( 'indexDocument' => 'home.html', 'errorDocument' => '404.html' )); // Success? var_dump($response->isOK());Result:
bool(true)
Source
Method defined in services/s3.class.php | Toggle source view (21 lines) | View on GitHub