I'm hosting a static website on AWS and want the naked domain to redirect to www. For example, if the user enters example.com I want it to show as www.example.com.
I found this question which is the exact same question as mine, but I want to ask a few more specifics before I take my site offline to change this.
I followed the AWS tutorial to deploy a static website. So if I want my root bucket to redirect to the www bucket, I will deploy the HTML/CSS/JS files to the www bucket and then set the root bucket to redirect?
Lastly, when I set the bucket policy. This is how the tutorial explained to do it for the root domain:
{
"Version":"2012-10-17",
"Statement": [{
"Sid": "Allow Public Access to All Objects",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::example.com/*"
}
]
}
I wouldn't need this anymore and instead would put this on the www bucket. However, do I change the Resource to www.example.com/*?
{
"Version":"2012-10-17",
"Statement": [{
"Sid": "Allow Public Access to All Objects",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::www.example.com/*"
}
]
}
So it would be
"Resource": "arn:aws:s3:::www.example.com/*"
Is that how you would set it up?