How to Host a Static Website on CloudFront With and Without the Www Subdomain?
If you followed the earlier tips on how to host your Octopress blog on either
Amazon S3
or Amazon CloudFront,
you’ll most likely wonder how to get your blog to be accessible from both http://www.mywebsite.com
and http://mywebsite.com
,
that is with or without the www
subdomain.
The bad news is that there is no way to define a CNAME
on a @
DNS record, so this can’t really be done.
This is not really an Amazon CloudFront restriction but more a DNS one.
You have to use a A
record, hence give an IP address.
Hopefully, there is at least one solution available (let me know if you are aware of other alternatives) using a service provided
by WWWizer. The way it works is to simply set your @
record to be their IP address, that
is 174.129.25.170
. This can be easily done adding this line into your DNS zone:
@ 10800 IN A 174.129.25.170
``
This redirect all your traffic on ``` http://mywebsite.com ``` to ``` http://www.mywebsite.com ``` via an HTTP 301 redirection.