2

When I visit a site of the form www.example.com/index.html on my AWS S3 hosted site, I expect to see the homepage. Instead I get redirected to www.example.com//

I have enabled S3 static website hosting and configured my index document as index.html

Can anybody help with what is going on here?

2
  • 1
    Straightforward maybe :) never seen that. If you look at index.html in the bucket, in metadata, it doesn't have an x-amz-website-redirect-location setting, does it? (It shouldn't). Also, the index document is just "index.html" and not "/index.html" -- right? Commented May 2, 2016 at 1:56
  • It seems to be working now but I can't seem to pin down what has changed. Whatever the problem was I think it was stuck in the cache of the Cloudflare CDN somewhere, which made it hard to diagnose (even though I disabled the CDN cache). On another note there was metadata on the index.html file which was redirecting to to the root of my domain, which caused an infinite loop (not to www.example.com// but to www.example.com/) Thanks for the tip on that one Michael! Commented May 2, 2016 at 9:36

2 Answers 2

3

The problem seemed to be down to dodgy routing rule:

<RoutingRules>
    <RoutingRule>
        <Condition>
            <KeyPrefixEquals>index.htm</KeyPrefixEquals>
        </Condition>
        <Redirect>
            <ReplaceKeyWith>/</ReplaceKeyWith>
        </Redirect>
    </RoutingRule>
</RoutingRules>

I achieved the routing I required by creating a file called index.htm and adding x-amz-website-redirect-location meta data to point to the root of the domain, thanks @michael-sqlbot

Sign up to request clarification or add additional context in comments.

Comments

2

You have to enable S3 static website hosting and configure you index document as index.html. Make sure you are accessing the endpoint website and not the S3 URL.

1 Comment

Unfortunately I've already taken that step and still not working - I have updated my question to reflect this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.