If you want to redirect (non-www to www) to your static website hosted on S3 and delivered by CloudFront, this guide is for you.
We will use such tools as:
At first, you need to create your S3 buckets. The main bucket name will be www.yourdomain.com
, the second one will be yourdomain.com
. When completed - upload static content to your main bucket, then complete static website hosting.
For yourdomain.com
named bucket use these settings:
Change your region to us-east-1
and go to Amazon Certificate Manager, reqest certificates for both of your domain names www.yourdomain.com
and yourdomain.com
. Don't forget to create CNAME records in Route53.
After getting certificates, go to CloudFront and create two ditributions. For Origin Domain Name use the S3 endpoint, don't use the autocompleted variant.
For Viewer Protocol Policy use Redirect HTTP to HTTPS.
CNAME for the main CloudFront distibution is going to be www.yourdomain.com
with your www certificate.
CNAME for the second CloudFront distibution is going to be yourdomain.com
with your non-www certificate.
Disable CloudFront caching.
For www.yourdomain.com
create A record with alias to CloudFront address according to www domain.
For yourdomain.com
create A record with alias to CloudFront address according to non-www domain.
Copyright © 2015-2020 Codica. It is released under the MIT License.
The names and logos for Codica are trademarks of Codica.
We love open source software! See our other projects or hire us to design, develop, and grow your product.