0

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?

Hooman Bahreini
  • 486
  • 6
  • 14

1 Answers1

1

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 for example.com so that when a user visits example.com, he/she will be redirected to www.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 it example.com, follow the steps to set up redirection, and finally change your DNS.

jellycsc
  • 137
  • 7
  • Are you able to add some more info please? – Hooman Bahreini May 11 '20 at 03:30
  • 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 for `example.com` so that when a user visits `example.com`, he/she will be redirected to `www.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 it `example.com`, follow the [steps](https://docs.aws.amazon.com/AmazonS3/latest/dev/how-to-page-redirect.html#redirect-endpoint-host) to set up redirection, and finally change your DNS. That's it. – jellycsc May 11 '20 at 03:40
  • Thanks for this, I think it would be more helpful for the future readers if you move the comment to your answer... at the moment, the main information about the answer is in the comment... – Hooman Bahreini May 11 '20 at 03:44
  • @HoomanBahreini Yeah, thanks for your suggestion. I have amended my original answer. – jellycsc May 11 '20 at 03:47