Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

amazon s3 - How to redirect non www to www in aws s3 bucket and cloudfront

I know how to redirect/rewrite non-www to www using .htaccess in apache server. But I have no clue, about s3 bucket, and CloudFront. I have hosted the website on an s3 bucket using CloudFront.

How do I redirect all http://example.com/ requests to http://www.example.com

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
  1. Create a www.example.com S3 bucket and place all the code in this bucket
  2. Create a example.com S3 bucket and set redirect to www.example.com as mentioned in https://aws.amazon.com/blogs/aws/root-domain-website-hosting-for-amazon-s3/
  3. Create CloudFront and configure with S3 bucket link of www.example.com and add cname entry only for www.example.com.
  4. In Route 53 for www.example.com point alias as CloudFront link related to S3 bucket
  5. In Route 53 for example.com point alias S3 bucket of example.com

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...