Path: blob/master/code_examples/php_examples/S3examples/s3-bucket-website-configuration.php
4084 views
<?php1// Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.2// SPDX-License-Identifier: MIT-0 (For details, see https://github.com/awsdocs/amazon-s3-developer-guide/blob/master/LICENSE-SAMPLECODE )34require 'vendor/autoload.php';56use Aws\S3\S3Client;78$bucket = '*** Your Bucket Name ***';910$s3 = new S3Client([11'version' => 'latest',12'region' => 'us-east-1'13]);141516// Add the website configuration.17$s3->putBucketWebsite([18'Bucket' => $bucket,19'WebsiteConfiguration' => [20'IndexDocument' => ['Suffix' => 'index.html'],21'ErrorDocument' => ['Key' => 'error.html']22]23]);2425// Retrieve the website configuration.26$result = $s3->getBucketWebsite([27'Bucket' => $bucket28]);29echo $result->getPath('IndexDocument/Suffix');3031// Delete the website configuration.32$s3->deleteBucketWebsite([33'Bucket' => $bucket34]);353637