Amazon S3 object redirect

Viewed 44248

Is it possible to put a redirect header on a s3-object? Like a 301 redirect.

For example:

mybucket.amazon-aws.com/myobject --> example.com/test

Preferably by setting a header like this on the object:

HTTP/1.1 301 Moved Permanently
Location: http://example.com/test
Content-Type: text/html
Content-Length: 0
6 Answers

Edit: See answer above as this functionality is now native in AWS

Not really no. There isn't an inbuilt feature which allows this, however, what you can do is to create your object and even if you don't save it as HTML, you can apply it as an HTML file.

For example:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="Refresh" content="0; URL=http://www.example.com/target/">
    <title>Redirect</title>
</head>

<body>
    <a href="http://www.example.com/target/">http://www.example.com/target/</a>
</body>
</html>

Look at this page here: View the source on it quickly.

view-source:http://carltonbale.com.s3.amazonaws.com/distance_chart.png

You can see an explanation here:

Point 8: http://carltonbale.com/9-hidden-features-of-amazon-s3

Related