I followed the instruction on S3 doc to host a static website there. Everything works with the domain name provided by S3. I can access "examplebucket.s3-website-us-east-1.amazonaws.com"
However, when I forward my own custom domain name, the domain name provider added a dot at the very end of my domain, then it's like I'm accessing "examplebucket.s3-website-us-east-1.amazonaws.com.", this won't work because Amazon thinks you're accessing a different address. And then give me 404 error.
Is there any workaround for this? or any place I should set up in S3?
I know this is too late for the original question but there may be more people with the same issues (me last week).
I was having the same issue while trying to create a route in route53 with CloudFormation. I was trying to redirect my domain www.example.com
to example-bucket.s3-website-eu-west-1.amazonaws.com
.
It turns out you cannot redirect to an arbitrary bucket. The bucket name must be the same as the domain you're trying to alias. So if you want to redirect www.example.com
, your bucket name must be www.example.com
and the URL must be www.example.com.s3-website-eu-west-1.amazonaws.com
.
Moreover cloudformation has a weird syntax. Cloudformation doesn't need the name of the bucket (it already knows it). It only needs the endpoint.
So instead of using something like
"AliasTarget": {
"DNSName" : "example-bucket.s3-website-eu-west-1.amazonaws.com",
"HostedZoneId" : "<zoneID>"
},
you need
"AliasTarget": {
"DNSName" : "s3-website-eu-west-1.amazonaws.com",
"HostedZoneId" : "<zoneID>"
},
And route53 where to redirect because the name of the route must be the same as the name of the bucket.
Related question https://stackoverflow.com/a/5048129/54256
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.