Dmitry Grinko
Dmitry Grinko

Reputation: 15204

How to add WWW to domain in AWS Route53?

I have created a Record Set

Name: www.nevermind.com.
Type: A
Alias Target: nevermind.com.

nevermind.com is working but www.nevermind.com is not working.

I get an error: 404 Not Found

update: I'm using s3 service to host my code.

Any ideas?

Upvotes: 9

Views: 8185

Answers (2)

mdeora
mdeora

Reputation: 4526

For s3 hosted websites - to enable the www subdomain for your domain, you need to do the following -

  • Create another s3 bucket with your subdomain name - www.nevermind.com

  • In the www.nevermind.com bucket choose properties -> static website hosting -> choose redirect requests -> in target bucket/domain put your domain "nevermind.com"

  • save

  • In route53 DNS record, create a new record set -> enter "www" for the Name -> select Alias: "Yes" -> use the "www.nevermind.com" s3 bucket alias endpoint.

After this, your www.nevermind.com should redirect to nevermind.com.

Upvotes: 21

mdeora
mdeora

Reputation: 4526

First verify in DNS Settings correct IP address is provided for the www entry - In route53 zone records you must see an entry with Name as www and value as IP address of your server.

Second - In your webserver's virtualhost settings you need to add both www and root domains, like below.

If you are using apache -

<VirtualHost *>
    ServerAdmin [email protected]
    ServerName www.nevermind.com
    ServerAlias *.nevermind.com nevermind.com
    ....
    ....
</VirtualHost>

If nginx -

server {
  listen 80;
  #listen 443 ssl default_server;
  server_name nevermind.com www.nevermind.com;
  ....
  ....

Upvotes: 0

Related Questions