download free 30 days trial version buy bucket explorer
Documentation  Download  Purchase  Support  FAQs   Forum   ScreenShots & Demos

Add Routing Rule with Amazon S3 Website using PUT Bucket Website

When you Configure an Amazon S3 Bucket as a Website , you can also specify "Routing Rules" to redirect requests to one Object to another Object for various reasons. For example, if you want to Delete an S3 Object (File)  from an Amazon S3 Bucket , which is configured from a website, you can define a Routing Rule to redirect the requests to that Object to another Object.

You can define Routing Rules by sending an HTTP PUT Request to Amazon S3 Server. To authenticate the request, you need to be the Bucket owner to be able to configure the website attached to a Bucket and you need to have S3:PutBucketWebsite permission. As Bucket owners, you may also W rite a Bucket Policy that grants S3:PutBucketWebsite permission to other users and allows them to set website configuration.

You can send HTTP PUT Request to Amazon Server to specify Routing Rules in two ways:

1) Use Amazon S3 APIs in your application code- If you are a programmer and want to write code, you can use Amazon S3 REST (described below) or SOAP API. Please read AWS documentation to get details on the SOAP API.

2) Use Bucket Explorer's User Interface for point and click- If you do not want to write a program, you can use Bucket Explorer to specify Routing Rules using the user interface.

1. Add Routing Rule using Amazon REST API

You can request PUT Bucket Website to set the s3 bucket as s3 website and also you can mention redirect rule (optional) with the configuration. It is the additional tag similar to IndexDocument and ErrorDocument, which could be passed with PUT Bucket Website request. You can mention your rule under the RoutingRules Tag. You can also mention number of rules.

Syntax:


PUT /?website HTTP/1.1
Host: bucketname.s3.amazonaws.com
Date: date
Content-Length: ContentLength
Authorization: signatureValue

<WebsiteConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<RoutingRules>
<RoutingRule>
<Condition>
<KeyPrefixEquals>docs/</KeyPrefixEquals>
</Condition>
<Redirect>
<ReplaceKeyPrefixWith>documents/</ReplaceKeyPrefixWith>
</Redirect>
</RoutingRule>
</RoutingRules>
</WebsiteConfiguration>
 

2. Add Routing Rule to S3 Website configuration using Bucket Explorer

You can use Bucket Explorer to set and configure (including routing rule) S3 Bucket as S3 Website by pointing and clicking and Bucket Explorer Interface.

Steps to redirect s3 website document on Amazon S3 using Bucket Explorer:

  1. First step is to sign up on Amazon S3.
  2. Download the latest version of Bucket Explorer and install it. Login to S3 using Bucket Explorer (Amazon S3 Tool).
  3. Create Bucket . Enter the name of the Bucket same as your website and select the region where you want to create Bucket.
  4. Select the newly created Bucket and Upload all web pages, images, CSS, and other static files from your desktop to your Amazon S3 Bucket.
  5. Set Permission on all objects of the Bucket as Public Readable .
  6. Now set S3 Bucket as S3 Website for more details see the doc - Set S3 Bucket as S3 Website – PUT Bucket Website .
  7. Now Select the S3 doc fo the bucket you want to redirect.
  8. Right click and choose Website Redirect Location menu and set the new location in Redirect page section. Here you can mention internal as well as external url.
  9. Click Set button.
  10. Now when you browse the older doc by S3 website url then it will show you new doc instead of old doc.