Covering both "www.domain.com" and "domain.com" in config file settings
What I like to do is explicitly set CRAFT_ENVIRONMENT in my index.php:

switch($_SERVER['SERVER_NAME']) {
  case 'domain.dev':
    define('CRAFT_ENVIRONMENT', 'LOCAL');
    break;
  case 'staging.domain.com':
    define('CRAFT_ENVIRONMENT', 'STAGING');
    break;
  case 'www.domain.com':
  case 'domain.com':
    define('CRAFT_ENVIRONMENT', 'PRODUCTION');
    break;
}


Then in the config file:

return array(
  '*' =&gt; array(
    // Settings here
  ),
  'LOCAL' =&gt; array(
    // Settings here
  ),
  'STAGING' =&gt; array(
    // Settings here
  ),
  'PRODUCTION' =&gt; array(
    // Settings here
  )
);


When you set CRAFT_ENVIRONMENT you may want to use the switch default for LOCAL or for PRODUCTION - there are good arguments for going either way.

A separate question is whether you should have people accessing your site at both www.domain.com and domain.com. The answer is most probably no. Pick one, and use .htaccess (on apache) or whatever other method, to redirect either all the www to non-www or the other way around. Otherwise you will have duplicate content, which confuses the search engines (and generally looks unprofessional).