I have noticed both google.com and amazon.com, redirect requests to www.google.com and www.amazon.com
I am thinking of doing the same for my website which is hosted on AWS. What is the best approach to do this? I am not sure if it would be better to implement this in Load Balancer or S3? Also is there any downside to always redirecting to www sub-domain?
You can simply create an S3 bucket and configure static web hosting to redirect the requests to
www
domain.More details:
Say your main website is
www.example.com
running on multiple EC2's behind an ALB and you want to set up a 301 redirection forexample.com
so that when a user visitsexample.com
, he/she will be redirected towww.example.com
. You don't need to change anything related to your existing main website domain (www.example.com
). The only thing you need to change is to add an S3 bucket and name itexample.com
, follow the steps to set up redirection, and finally change your DNS.