Amazon Web Services

Playing with www and non-www in AWS using Route53

Deep
Written by Deep

In AWS EC2 sometime we  need to redirect our domain from www to non-www version or vice-versa. We can do this with the help of Route53 and htacess file on your server.

Redirect your domain www.xyz.com to xyz.com –

  • You need to create a new record set of CNAME:
    Go to Route53 > Hosted Zones > Slecect Your domain and Create a New Record set with following details :
    (Please replace xyz.com with your domain name)

           Name:   www.xyz.com
           Type: CNAME
           Alias: No
           TTL (Seconds): 300
           Value: xyz.com

           and save it.

  • Add .htaccess file to root directory of your domain

 

Redirect your domain xyz.com to www.xyz.com

  • In Route53 create a Type A (alias) record set (for example.com).
    On the EC2 instance /etc/httpd/conf.d/vhost.conf create an entry that redirects all traffic to https://www.example.com
  •  

 

1 Comment

Leave a Comment