If you need to do a 301 redirect between multiple domain names, and force all domains to direct to the "www", use the following code in your .htaccess file.
RewriteCond %{HTTP_Host} ^(www\.)?secondary-domain1\.com$ [NC]
RewriteRule ^(.*)$ http://www.maindomain.com/$1 [L,R=301]
RewriteCond %{HTTP_Host} ^(www\.)?secondary-domain2\.com$ [NC]
RewriteRule ^(.*)$ http://www.maindomain.com/$1 [L,R=301]
RewriteCond %{HTTP_Host} ^maindomain\.com$ [NC]
RewriteRule ^(.*)$ http://www.maindomain.com/$1 [L,R=301]
And that's how you would do a 301 redirect between multiple domain names, and force the "www" version of your main domain. The code above is for a .htaccess file on an apache server.
On a fresh install of Drupal, you'll encounter issues with how your website's domain can be accessed. Out of the box, you'll be able to access your site both with and without the "www" prefix. This can be a problem for Drupal SEO, as the potential exists for search engines to think your website contains duplicate content, even when it doesn't. This isn't a fix that will lead to dramatic improvements, but it's a good SEO best practice for Drupal sites.