Here is few examples how to create a redirect from using .htaccess file:
This redirect allows to redirect all requests from www.yoursite.com to yoursite.com (why it should be done? Google skip mirrored sites, for example www.yoursite.com and yoursite.com are different sites for Google, so some pages can be indexed only for www.yoursite.com and some only for yoursite.com, as a result your domain loses Google Page Rank, so you should decide which of them will be used).
Redirect from WWW to NON-WWW
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^yoursite.com [NC]
RewriteRule ^(.*)$ http://www.yoursite.com/$1 [L,R=301]
Redirect from NON-WWW to WWW
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^yoursite\.com
RewriteRule (.*) http://yoursite.com/$1 [R=301,L]
Redirect from NON-WWW and WWW to another path
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^yoursite.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.yoursite.com$
RewriteRule ^(.*)$ http://someurl.com/ [R=301]