Skip to content

S3 Static Website Redirect Bucket Not Working for Root Domain

0

Hello,

I am trying to set up a static website redirect using S3 for my root domain (owenhamlin.com). My goal is to redirect all traffic from owenhamlin.com to www.owenhamlin.com, which is hosted in a separate S3 bucket.

Here are the details of my setup:

  • I have two S3 buckets in the same region (us-west-1):
    • owenhamlin.com (configured for static website hosting, set to “Redirect requests for an object” with host name www.owenhamlin.com and protocol http)
    • www.owenhamlin.com (configured for static website hosting, serves my actual website)
  • Block all public access is OFF for both buckets.
  • No bucket policy is set on the redirect bucket.
  • The bucket website endpoint for the redirect bucket is:
    http://owenhamlin.com.s3-website-us-west-1.amazonaws.com
  • When I visit this endpoint, the page loads forever and never redirects.
  • The www bucket endpoint works as expected.
  • I have tried:
    • Recreating the redirect bucket
    • Toggling static website hosting settings
    • Changing the protocol between http and none
    • Testing from different browsers and networks

Question:
Is there anything else I should check, or is there a known issue with S3 static website redirects in us-west-1? Why does my redirect bucket endpoint not redirect as expected?

Thank you for your help!

3 Answers
0

After going through the links you provided, I think the redirection is working fine but the page is not loading. I think it's redirecting to the https version of the website, however, note that https is not supported for S3 static website, which is probably it's not loading. For S3 website, you need to use http. If https is a must, and ideally should be for external websites, consider using cloudfront.

https://docs.aws.amazon.com/AmazonS3/latest/userguide/how-to-page-redirect.html https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/getting-started-cloudfront-overview.html

EXPERT

answered a year ago

EXPERT

reviewed a year ago

  • thank you for your review, where would I make this adjustment?

  • I'm assuming you have configured the redirect in S3 website setting. There, instead of pointing to https://... change that to point http://... URL. Or did you use other method for redirect like just having an index.html and javascript redirect?

0

Sounds like you're trying to do what I do with my site.

I have two buckets called mysite.net and www.mysite.net, both with Static website hosting enabled, with the bucket website endpoint of each bucket being http://mysite.net.s3-website-ap-southeast-2.amazonaws.com and http://www.mysite.net.s3-website-ap-southeast-2.amazonaws.com respectively.

Route 53 hosted zone is setup like this:

Enter image description here

This works for me. Can you try similar (obviously using Northern California region instead of Sydney)?

EXPERT

answered a year ago

-1

The issue you're experiencing with your S3 bucket redirect not working properly could be due to several factors:

  1. Bucket Configuration: When setting up a redirect bucket, make sure you've selected "Redirect requests" as the hosting type (not "Host a static website") in the static website hosting configuration. This is a common mistake that prevents redirects from working properly.

  2. Protocol Setting: For the redirect configuration, ensure you've correctly specified the protocol. If your www site uses HTTPS, make sure to select "https" in the protocol dropdown rather than "http" or "none".

  3. Formatting of the Host Name: Double-check that the host name is correctly formatted. It should be exactly "www.owenhamlin.com" without any extra characters, slashes, or protocol prefixes.

  4. Permissions: While you mentioned that Block Public Access is turned off, you might still need a bucket policy that explicitly allows public read access. For a redirect bucket, you should have a policy that includes the s3:GetObject permission for public access.

  5. Propagation Time: Changes to S3 website configurations can sometimes take time to propagate fully. Wait a few minutes after making changes before testing again.

  6. Browser Cache: Your browser might be caching previous responses. Try clearing your browser cache or testing in an incognito/private browsing window.

  7. Testing Method: Make sure you're testing using the S3 website endpoint URL (http://owenhamlin.com.s3-website-us-west-1.amazonaws.com) and not the S3 API endpoint. Redirects only work when accessing through the website endpoint.

If you've verified all these settings and the redirect still isn't working, there could be an issue with how the redirect is being processed. In that case, you might want to consider creating a support case with AWS for more specific assistance with your configuration.
Sources
S3 website-redirect-location not redirecting | AWS re:Post
Domain Redirect on S3 missing colon https// | AWS re:Post
CloudFront cache and S3 bucket redirect issue | AWS re:Post

answered a year 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.