Question

Virtual host / domain only works without www. prefix

Would like to know where i’m making a mistake with the 2 sites i have that i can only access like : site.com instead of www.site.com

I have 3 domains / virtual hosts setup and 1 of them is working perfectly. However the 2 other are setup identical but have this problem.

I did also sudo service apache2 reload to take the new settings but nothing has happened.

Thank you very much for your help.

Subscribe
Share

@nepsilon Did you add prefix “www” in your domain while adding it here: https://cloud.digitalocean.com/networking/domains Like if you add your domain as: mysite.com, you won’t be able to access it with www. Add both with and without www prefix to access your website in both conditions. I hope this helps.

I have added cname but however on 1 of the sites i am experiencing this :

Site down or blocked

www.mysite.com is down or blocked.

Check your internet connection and retry Retry Access

Any hints ? Thank you.

The other site is resolved and works perfectly, thank you very much for your effort.

I am getting

This webpage is not available ERR_NAME_NOT_RESOLVED

I do have control and they are setup exactly as the previous one that actually works.

Do you get the error message - Server not found? If yes, it means your DNS isn’t configured correctly. Do you have control of your DNS records? You should create a CNAME record for “www”.site.com that points to site.com. Or you can create an A record for “www”.site.com that resolves to the same ip address as site.com.

com.conf file looks like this

ServerAdmin admin@mysite.com ServerName mysite.com ServerAlias www.mysite.com DocumentRoot /var/www/mysite.com/html


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

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.

Hi!

Based on the error message you’re receiving (NAME_NOT_RESOLVED), there is an issue with DNS records for this domain that is preventing it from resolving outside of the ‘www’ subdomain. To correct this, you will need to update the DNS records for this domain to ensure that the root domain resolves to the same IP address as the ‘www’ subdomain (with an A record of its own), or else that it contains a CNAME record pointing to the ‘www’ subdomain, which will result in it resolving to the same IP address as the subdomain by default.

Hope this helps!

DigitalOcean Support

This comment has been deleted