Site not working with www

Posted May 5, 2013 69.6k views
My site is reacheable only without www. I have added a CNAME record: www but it still doesn't work. Any suggestion ?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

15 answers
I added two cname on DNS an it works!!
Look the screenshot

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.

I signed up just to add my solution, I spent days trying to figure out how to get the WWW version to work! I have hosting at Cloudways btw. So the first part is you need an A record with WWW pointed at your server IP address. But to really make it work I needed to add my WWW domain version to my SSL certificate on Cloudways. I already had “” but needed to add “” to the SSL. You need to add the www A record first before your SSL will update. In about an hour the www version will work.

I hope that saves a few people some time and hassle! Trying to edit the htaccess file and redirecting domains was not the solution I needed.

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

You can either replace the CNAME record with an A record, or change the CNAME record's value to ""
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} ^$
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 is online BUT is not accessible..

here is what is in the /etc/apache2/sites-available/


I have added www in "name" column + 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 “ —”

I have just added
Name :

Submit an Answer