Adjust DNS settings for example.com. Make sure you have address records (type A records) for example.com and www.example.com with the same IP address.
If you use shared hosting to provide multiple websites at the same IP address, you also need to tell the web server about the alternate name for the site. In the configuration of your web server, add example.com as an alias for www.example.com. In the Apache server httpd.conf file, this usually looks like this:
<VirtualHost *> DocumentRoot /home/www/web ServerName www.example.com ServerAlias example.com </VirtualHost>
http://www.boutell.com/newfaq/creating/withoutwww.html
source share