Go back to home page of Unsolicited Advice from Tiffany B. Brown

Setting URL redirects with S3

During my migration from WordPress to Pelican/S3, I also decided to move around some content. Yes, I know Cool URIs don't change. But I wanted to consolidate content at a few URLs, and use HTTP redirects to help you find the new stuff.

Setting up a redirect using S3 is easy-peasy: you must edit the file's metadata. You can either do this from the AWS Console, programmatically, or with a file manager such as Cyberduck.

Using the AWS Console

  1. Log in to the console, and go to the S3 screen (under Storage & Content Delivery).
  2. Navigate to the bucket and file you wish to redirect from.
  3. Select the file, and click the Properties button in the upper right side of the screen.
  4. Open the Metadata section, and click the Add metadata or Add more metadata button.
  5. In the Key field, select or type Website Redirect Location.
  6. In the Value field, enter the path relative to the base URL, or full URL of the redirect destination.

Using Cyberduck (or other file transfer software)

  1. View the file's metadata. In Cyberduck, that's the Info command (Command + I or File → Info). Other applications may refer to this metadata as Edit Headers/View Headers or the like.
  2. Add a header named x-amz-website-redirect-location.
  3. Set its value to path relative to the base URL, or full URL of the redirect destination (Figure 1).
Figure 1: Viewing and editing headers in Cyberduck.

Usually redirects kick in immediately, but occasionally, it will take a minute or two to propagate.