Redirecting non-www to www with .htaccess

How to redirecting non-www to www with .htaccess for all page's? in my main page(index) works, but if i go mywebsite.com/page2, will not redirect me to my preference domain www.mywebsite.com/page2. How can i fix it?

the $1 parameter passes everything after .com to the rewritten url
it should work
except when something is missed or changed on the server config.
many servers are locked down, and if the locking is . .. . less than perfect . ..
try

line 4, there should not be a nocase [NC] flag it should be L,
rewrite condition in line 3 creates an infinite loop
search for mysite.com in the host string, redirect to www
then do it again to the redirect url, and again and again

the code samples given all have a rewrite conditionRewriteCond %{HTTP_HOST} !^www\.
search for url that do NOT include www., and redirect to www.