Do I also need to add separate code such as that below to redirect http://mydomain.com/ to http://www.mydomain.com/? Or does the above code accomplish both? (Because both redirects seem to be already working, I'm just not sure why it's already redirecting for http://mydomain.com/)
RewriteEngine on
RewriteCond % ^mydomain.com [NC]
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [L,R=301]
Also, is it necessary to set the preferred domain in google webmaster tools to www.mydomain.com if I am using these 301 redirects?