问题
Hi I am looking for the best way to redirect / route all s3 bucket links to a domain or link domain to s3 bucket.
I am migrating from dedicated hosting to aws and using s3 bucket to store files.
Example: http://www.example.com.au/app --> directs to http://examplebucket.s3.amazonaws.com/app
But i have heaps of them and hybrid apps that point to domain/files so not sure if theres a way to route within aws console or php script to achieve?
Thanks
回答1:
You can point a custom domain name to an Amazon S3 bucket, if the bucket is named the same as the domain name.
So, if you own the domain name example.com
, you can point www.example.com
to a bucket called www.example.com
with these steps:
- Create the bucket with the matching name
- Turn on Static Website hosting and copy the displayed URL
- Create a Route 53 Record Set for
www.example.com
point it to the URL copied earlier
See documentation: Setting Up a Static Website Using a Custom Domain
Update: As pointed out by sqlbot, another option is to use Amazon CloudFront in front of Amazon S3. This has several benefits:
- The bucket name does not need to match the domain name
- The domain name can point to several different origins (eg
/images
could come from one bucket and/css
could come from another) - It supports
HTTPS
(which is not possible when going direct to Amazon S3 because the URL resolves to a generic S3 IP address)
来源:https://stackoverflow.com/questions/42108491/redirect-route-s3-bucket-to-domain