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
- Log in to the console, and go to the S3 screen (under Storage & Content Delivery).
- Navigate to the bucket and file you wish to redirect from.
- Select the file, and click the Properties button in the upper right side of the screen.
- Open the Metadata section, and click the Add metadata or Add more metadata button.
- In the Key field, select or type Website Redirect Location.
- 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)
- 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.
- Add a header named
- Set its value to path relative to the base URL, or full URL of the redirect destination (Figure 1).
Usually redirects kick in immediately, but occasionally, it will take a minute or two to propagate.