amazon-web-servicesno-www

How to set up no-www with AWS?


I own a site on AWS with Route 53. I want the site to be accessible without the www at the beginning, but am having trouble.

For the example the site name is domain.com. What I've attempted is creating an A record in the Record Set for my Route 53 site, with the name domain.com and target www.domain.com, in hope that this would let searching domain.com lead to www.domain.com. This didn't work, giving me an error for an invalid name value.

How do I get my AWS Route 53 domain to run without www at the beginning using the record sets in Route 53?


Solution

  • Associate a A record or Alias with your top level domain name.

    Just associate the same A record or Alias to your www record.

    Here is an example from my domain :

    stormacq.com.      A     Alias <my cloudfront distribution ID>
    www.stormacq.com.  A     Alias <my cloudfront distribution ID>
    
    
    $ dig stormacq.com +noall +answer
    
    ; <<>> DiG 9.10.6 <<>> stormacq.com +noall +answer
    ;; global options: +cmd
    stormacq.com.       44  IN  A   54.230.3.162
    stormacq.com.       44  IN  A   54.230.3.70
    stormacq.com.       44  IN  A   54.230.3.190
    stormacq.com.       44  IN  A   54.230.3.146
    
    
    $ dig www.stormacq.com +noall +answer
    
    ; <<>> DiG 9.10.6 <<>> www.stormacq.com +noall +answer
    ;; global options: +cmd
    www.stormacq.com.   60  IN  A   54.230.3.190
    www.stormacq.com.   60  IN  A   54.230.3.70
    www.stormacq.com.   60  IN  A   54.230.3.162
    www.stormacq.com.   60  IN  A   54.230.3.146
    

    Both names are defined in CloudFront Distribution configuration. So, no redirection is needed, Cloudfront will happily serve both names.