Site not working with www

May 5, 2013 55.7k views
My site is reacheable only without www. I have added a CNAME record: www xxx.xxx.xxx.xxx but it still doesn't work. Any suggestion ?
2 comments
  • why the hell isn’t DigitalOcan adding the dns essentials records when a domain i added? That includes the www, etc. and the rest

  • Try adding two cnames DNS, am sure it will work!
    If this doesn’t work, change the CNAME record’s value to “ligneetbienetre.ch.” this will work.

    edited by aha
15 Answers
I added two cname on DNS an it works!!
Look the screenshot http://i.imgur.com/3AJGBJO.jpg

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.

Do you have a virtualhost listening on the www. domain?
Yes, here is what I see in httpd.conf:


ServerName ligneetbienetre.ch
ServerAlias www.ligneetbienetre.ch
You can either replace the CNAME record with an A record, or change the CNAME record's value to "ligneetbienetre.ch."
Thanks for your help, everything is working now.
Thank you! I was desperately in need of this answer also.
Or why you not give a try and use the htacces file (if mod_rewirte enable):

RewriteEngine on
RewriteCond %{HTTP_HOST} ^youdomainname.com$
RewriteRule ^(.*)$ "http\:\/\/www\.youdomainname\.com/$1" [R=301,L]

:)
Thank you David E.! This worked like a charm!
It is happened to my site too

kancingdoortrim.com is online BUT www.kancingdoortrim.com is not accessible..

here is what is in the /etc/apache2/sites-available/kancingdoortrim.com:

ServerName kancingdoortrim.com
ServerAlias www.kancingdoortrim.com

I have added www in "name" column + kancingdoortrim.com. in the "hostname" via "add CNAME record" inside the DNS menu of digitalocean account but still no differences.

the www still not working
it works after I installed wordpress, could it be due wordpress' .htaccess handle the www redirection up?

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.

Thanks it works,

Its allows me add only “www.domain.com. — domain.com.”

I have just added
Name : www.domain.com.
Hostname: domain.com.

Have another answer? Share your knowledge.