If you're using AWS's Route53 with ELB this isn't a problem to point the example.com
to an ELB CNAME record. Short of that it has to be done by a service rather than through DNS because of RFC 1034 section 3.6.2 paragraph 3 which reads:
... If a CNAME RR is present at a node, no other data should be
present; this ensures that the data for a canonical name and its
aliases cannot be different. This rule also insures that a cached
CNAME can be used without checking with an authoritative server for
other RR types.
In other words it states that you can not have a CNAME RRset with any other RRset and a domain name record requires at a minimum 2 RRsets (SOA & NS) there by making it mutually exclusive with a CNAME RRset.
GoDaddy gets around this by offering domain Forwarding
on their DomainManager details for the Domain Information. This updates the DNS record for your domain to point to one of their servers and it redirects the web-based domain requests to another URL. I utilize this for several domains that I have hosted with GoDaddy and running behind AWS ELBs. You just point the entry for www.example.com
to your ELB CNAME RRset and then with the Forwarding in enable it'll be redirected as expected.
To accomplish the same without using GoDaddy, you would have to have a host with a static IP, or EC2 instance with an EIP, running Apache or some other web server that could simply issue a 301 or 302 redirect back to www.example.com
. I have also found that EasyDNS also offers a URL forwarding feature the appears to provide the same functionality as GoDaddy's but I have not had a chance to try it out.