Redirect www to Root with Route 53 and S3
This guide provides step-by-step instructions to redirect www.example.com to example.com using AWS Route 53 and S3.
Step 1: Create an S3 Bucket for www.example.com
Go to the S3 console in AWS and create a new bucket named www.example.com
. The bucket name must match the domain you want to redirect from.
Step 2: Configure the S3 Bucket for Redirection
After creating the bucket, configure it for website redirection.
- Open the bucket settings for
www.example.com
. - Enable Static website hosting.
- Set it to redirect requests to
example.com
with HTTPS protocol.
Step 3: Configure Route 53 to Redirect www.example.com to example.com
Now, set up a Route 53 alias record to direct traffic from www.example.com
to the S3 bucket.
- Open the Route 53 console in AWS and navigate to your hosted zone for
example.com
. - Click on Create record.
- For Record name, enter
www
. This will create the subdomainwww.example.com
. - Set Record type to
A - IPv4 address
orAlias
. - Under Route traffic to, choose Alias to S3 website endpoint.
- In the S3 bucket list, select
www.example.com
. This links the record to the S3 bucket configured for redirection. - Save the record.
This configuration routes all traffic from www.example.com
to the S3 bucket, which redirects it to example.com
.
Step 4: Test the Redirection
Go to http://www.example.com to verify it redirects to https://example.com.