Search code examples
urlamazon-s3http-redirectstatic-site

Browser bar URL changes itself for S3 website


I've set up an s3-hosted static website using the AWS walkthrough. I've also followed the walkthrough to get a domain name using route53 that forwards to the site (by creating a RecordSet with type A-IPV4 and specifying the alias as the s3 bucket). This sort of works. I can see the content fine - entering mything.com into the browser's url bar brings up the correct page.

But the browser's url bar automatically changes to http://mything.com.s3-website-us-west-1.amazonaws.com. I don't want that - I want the url bar to keep displaying mything.com. Is there a way to do that?


Solution

  • I think I've fixed it. Problem was that, as per the walkthrough, I'd set up two S3 buckets called mything.com and www.mything.com. Then I set www.mything.com to redirect to the other bucket. The problem was that in the AWS redirect field, I'd entered the other bucket's endpoint, rather than just its name. In a browser, when I went to www.mything.com I was getting a 301 redirect to the full s3 endpoint. In chrome 47, the 301 redirect was cached and was then also applying (slightly intermittently) even when I entered mything.com into the url bar. After fixing the redirect in the aws console, I needed to kill my recent browsing history in chrome to get rid of the cached 301 redirects.