How to route the domain with www and without to one location?

  • Posted October 7, 2014

My DNS settings are as follows:

$TTL	1800
@		IN	SOA	NS1.DIGITALOCEAN.COM.	hostmaster.[]. (
			1412671879 ; last update: 2014-10-07 08:51:19 UTC
			3600 ; refresh
			900 ; retry
			1209600 ; expire
			1800 ; ttl
             IN      NS      NS1.DIGITALOCEAN.COM.
                     NS      NS2.DIGITALOCEAN.COM.
                     NS      NS3.DIGITALOCEAN.COM.
			MX 10
			MX 20
www	CNAME	@

The problem is that the domain without www loads index.html in ( /var/www/index.html) and with www loads (/var/www/

How can I fix this issue?


Two questions for you:

are you using apache2? what would you like to see happen? (someone types in and it resolves to…or the opposite…)

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.

I’m using apache2. And the problem is that the domain with www and without it should open the same index.html which they do not.

It’s probably your server configuration. It sounds like you have a configuration for a server with the name and a server root of /var/www/ Apparently /var/www/ is the server root for the default domain, which you are seeing because you don’t have a configuration for You should be able to just add as a server name for the configuration.