如何在AWS S3存储桶和CloudFront中将非www重定向到www [英] How to redirect non www to www in aws s3 bucket and cloudfront
问题描述
我知道如何使用apache服务器中的.htaccess将非www重定向/重写为www.但是我对s3 bucket和CloudFront一无所知.我已经使用CloudFront将网站托管在s3存储桶中.
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.
如何将所有 http://example.com/请求重定向到
How do I redirect all http://example.com/ requests to http://www.example.com
推荐答案
S3中有一个功能,您可以在其中使用.选择一个存储桶,在静态网络托管下的属性中,选择将所有请求重定向到另一个主机名.
There is a feature in S3 where you can to this. Select a bucket, in Properties under Static Web Hosting select Redirect all requests to another host name.
在此处了解更多信息: https://aws.amazon.com/blogs/aws/root-domain-website-hosting-for-amazon-s3/
Read more here: https://aws.amazon.com/blogs/aws/root-domain-website-hosting-for-amazon-s3/
评论更新:在域设置中为example.com添加一个cname,以指向您的存储桶终结点;为您的www.example.com添加一个cname,以指向cloudfront终结点.
Update from comment: Add a cname in your domain setup for example.com to point to your bucket endpoint and a cname for your www.example.com to point to the cloudfront endpoint.
这篇关于如何在AWS S3存储桶和CloudFront中将非www重定向到www的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!