User experience remains one of the most important factors when operating a website. User experience enhances your conversions, increases time spent on page and in directly improves rankings due to an increase of people wanting to link to your site. Having a site not accessible via both with or without
www causes a few user experience problems, the biggest problem would be what if people manually type your domain with or without
www directly into the address bar, a browser returning
Server not found could loss you a site visitor and the less visitors you have the less chance of social mention and back linking opportunities.
So having a site that is not accessible by both means would definitely dampen user experience as well as missing out on SEO opportunities.
Google and many other search engines reward websites that gain quality back links, should it be a blog link, a forum link or even a social mention all these typical examples are quality ways of easily increasing your website naturally. A website that receives a link to
http://www.example.com but is only accessible typing
http://example.com is not gaining any SEO value from that link. This is because Google only passes link credit to pages and websites that are accessible after-all who wants to click something to get ‘server not found’.
Solution Part 1 (Domain DNS)
You should proceed by setting up your domain DNS to work with both
example.com, this can be found by either changing your name servers to that of the web server or pointing AA/AAAA record to the domain and the sub domain with www using a cname alias. This setup procedure differs from registrar to registrar.
Solution Part 2 (301 Redirecting)
You should redirect all site visitors and bots to the preferred version of your website of course this step isn’t required but it helps track visitors and backlinks gained are mostly likely to the preferred version, links received that are 301 redirected loss a minor amount of credit. Also redirecting some what does slow down the page loading because of the initial bounce.
If using Apache2 as your web server then I recommend checking out what are the most commonly used and basic Apache htaccess redirects or in the event you are using Windows Server IIS then you should check out Microsoft's URL rewrite extension.
Solution Part 3 (Optional Canonical Links)
It is recommended these days use canonical links to help search engines establish the page, if the site is accessible with and without
www without a 301 redirect this step is pretty much a must as Google and other bots can mistakenly index your non preferred version. Also canonical links help prevent duplicate content unrelated to
www so even without the topic of www or not www it’s a helpful thing to have because you may have content accessible on different sub paths never mind the sub domains.