Really all that is necessary is this:
Go Settings -> General: WordPress Address (URL) Site Address (URL)
And set both of them to www.yoursite.com (instead of yoursite.com), wordpress automagically takes care for setting all the urls to www.yoursite.com and that’s it.
If that isn’t enough:
Install the Redirection plugin and you can just set the options to *.mydomain.com/* to redirect to www.mydomain.com/* with a 301, and that will take care of your htaccess as long as you keep the plugin active.
It is a good idea to use the Redirection plugin instead of directly editing your htaccess plugin, as anytime you save or reload your permalink settings, WordPress will overwrite your .htaccesss (some plugins may do that as well).