This method uses a 301 redirect to establish a permanent redirect from the www-version of a domain to its respectively corresponding non-www version. Be sure to test immediately after preparing 301 redirects and remove it immediately if any errors occur. Use a server header checker to confirm a positive 301 response. Further, always include a trailing slash / when linking directories. Finally, be consistent with the www in all links (either use it always or never).
# permanently redirect from www domain to non-www domain
RewriteEngine on
Options +FollowSymLinks
RewriteCond %{HTTP_HOST} ^www\.domain\.tld$ [NC]
RewriteRule ^(.*)$ http://domain.tld/$1 [R=301,L]
this is very important from SEO point of view