Root domain config overriding subdomain config My question is similar to Subdomain database configuration picking up root domain config, but I don't have any custom database variables. 

I have a staging site and a (forthcoming) production site on the same remote shared hosting server. The staging site is at a staging subdomain and the production site will be at the root. 

The staging site seems to be using the config variables from the root domain in general.php and db.php. I had to take the production site out of db.php to get the staging site to work at all, and anywhere I'm using environment variables (like my asset paths), they're coming from the production config instead.

This is my general.php:

return array(
  '*' =&gt; array(
    'omitScriptNameInUrls' =&gt; true,
    'generateTransformsBeforePageLoad' =&gt; true,
    'loginPath' =&gt; 'admin',
  ),
  'localhost' =&gt; array(
    'server' =&gt; 'localhost',
    'devMode' =&gt; true,
    'environmentVariables' =&gt; array(
      'basePath' =&gt; 'C:\wamp\www\craftcms',
      'baseUrl'  =&gt; 'localhost/craftcms/',
    )
  ),
  'staging.safs.msu.edu' =&gt; array(
        'server' =&gt; '35.8.12.67',
    'devMode' =&gt; true,
    'environmentVariables' =&gt; array(
      'basePath' =&gt; 'staging',
      'baseUrl'  =&gt; 'http://staging.safs.msu.edu',
    ),
  ),
  'safs.msu.edu' =&gt; array(
    'server' =&gt; '35.8.12.67',
    'devMode' =&gt; false,
    'environmentVariables' =&gt; array(
      'basePath' =&gt; '',
      'baseUrl'  =&gt; 'http://safs.msu.edu',
    ),
  ),
);


How do I get my config files to recognize the staging subdomain's settings?
Craft looks for partial matches to apply config settings (both general.php and db.php which means you can do things like:

'.dev' =&gt; array(
.. 

'.com' =&gt; array(
..


Craft applies these settings for each match from the top of the file to the bottom. So in your case because you have the the production domain after your subdomain config it matches and overrides your subdomain settings. 

Simply swap your config variables over and it'll work.

return array(
  '*' =&gt; array(
    'omitScriptNameInUrls' =&gt; true,
    'generateTransformsBeforePageLoad' =&gt; true,
    'loginPath' =&gt; 'admin',
  ),
  'localhost' =&gt; array(
    'server' =&gt; 'localhost',
    'devMode' =&gt; true,
    'environmentVariables' =&gt; array(
      'basePath' =&gt; 'C:\wamp\www\craftcms',
      'baseUrl'  =&gt; 'localhost/craftcms/',
    )
  ),
  'safs.msu.edu' =&gt; array(
    'server' =&gt; '35.8.12.67',
    'devMode' =&gt; false,
    'environmentVariables' =&gt; array(
      'basePath' =&gt; '',
      'baseUrl'  =&gt; 'http://safs.msu.edu',
    ),
  ),
  'staging.safs.msu.edu' =&gt; array(
    'server' =&gt; '35.8.12.67',
    'devMode' =&gt; true,
    'environmentVariables' =&gt; array(
      'basePath' =&gt; 'staging',
      'baseUrl'  =&gt; 'http://staging.safs.msu.edu',
    ),
  ),
);