Search code examples
dnsamazon-route53aws-application-load-balancer

How to Point www and Non www site to an ALB in Route53


I want to point www.example.com and example.com to a server behind the ALB in such a way that whenever someone types www.example.com or example.com he will always go to www.example.com. following are my records

example.com         A    simple    yes     dualstack.[alb].com
example.com         NS   simple    no      ns.[].com etc....
example.com         SOA  simple    no      ns.[].com etc...
www.example.com     A    simple    yes     dualstack.[alb].com (same as the first record in the list)

currently it is always going to exmple.com regardless of what we type example.com or www.example.com and site is working perfectly. But I want to alway go to www.example.com regardless of what I type in the search bar www.example.com or example.com....

What records should I put here to achieve this task???


Solution

  • Please ensure that the redirection is not done by your application server.

    Assuming that you use Application Load Balancer you could use listener rules to handle redirection to www. domain.