By using AWS re:Post, you agree to the Terms of Use

CloudFront's "Origin Path" does not work with S3 Static Website's 302 redirects


I have an S3 bucket with static website hosting with the following file:


I have created a CloudFront distribution pointing to this bucket, with the Origin Path set to "/production". When navigating to I can correctly see my index.html file.

When navigating to (without the trailing slash), the S3 static site hosting sends a 302 redirect to, which ignores the Origin Path and returns a 404.

How can I make my system work to be able to have the redirection to instead?

1 Answers
Accepted Answer

I was able to solve it by having the following redirection on my S3 static website. Not the best solution because this causes 2 redirections, but it works.

        "Condition": {
            "KeyPrefixEquals": "production/production/"
        "Redirect": {
            "HostName": "",
            "HttpRedirectCode": "302",
            "Protocol": "https",
            "ReplaceKeyPrefixWith": ""
answered 14 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions