If it is a wordpress installation, you also need to make sure that the siteurl for the wordpress website starts with www, else you will get the same problem.
markosweb’s answer works. You just have to wait a while before the changes take effect. Thanks!
I tried the suggestion below by markosweb (June 5, 2014).
Error: CNAME records cannot share a name with other records
I’ll try the other method with .htaccess file.