I asked the same question Redirect to site if WWW part is missing but the answer did not helped in my case, as i was unable to get to change the CNAME and .htaccess also failed.
The only option left is to use PHP.
Can anyone help me ?
If someone tries to browse example.com or example.com/ or so the PHP will redirect it to www.example.com/..
edit
SetEnv TZ Asia/Calcutta
ErrorDocument 400 /error.html
ErrorDocument 401 /error.html
ErrorDocument 403 /error.html
ErrorDocument 404 /error.html
<ifModule mod_php4.c>
php_value zlib.output_compression 16386
</ifModule>
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule ^home$ home.php [L]
RewriteRule ^credit$ credits.php [L]
RewriteRule ^credits$ credits.php [L]
RewriteRule ^profile/(\d+)/?$ profile.php?id=$1 [L]
RewriteRule ^user/(\d+)/?$ view_profile.php?id=$1 [L]
RewriteRule ^blog/?$ blog.php [L]
RewriteRule ^blog/(\d+)/?$ blog.php?id=$1 [L]
RewriteRule ^blog.php/(\d+)/?$ blog.php?id=$1 [L]
RewriteRule ^blog/(\d+)/([A-Za-z0-9-_\[\]]+)/?$ blog.php?id=$1&title=$2 [L]
RewriteRule ^blog.php/(\d+)/([A-Za-z0-9-_\[\]]+)/?$ blog.php?id=$1&title=$2 [L]
RewriteRule ^blogbyauthor.php/(\d+)/?$ blogbyauthor.php?uid=$1 [L]
RewriteRule ^blogbyauthor/(\d+)/?$ blogbyauthor.php?uid=$1 [L]
RewriteRule ^blogbyauthor/(\d+)/?$ blogbyauthor.php?uid=$1 [L]
RewriteRule ^blog_by_category.php/([A-Za-z0-9-_\[\]]+)/?$ blog_by_category.php?category=$1 [L]
RewriteRule ^blog_by_category/([A-Za-z0-9-_\[\]]+)/?$ blog_by_category.php?category=$1 [L]
</IfModule>