2

So I have this example database config setup

$customDbConfig = array(

    '*' => array(
        'tablePrefix' => 'craft',
    ),

    'test1.foo.com' => array(
        'server' => 'localhost',
        'user' => 'test1user',
        'password' => '',
        'database' => '',
    ),

    'test2.foo.com' => array(
        'server' => 'localhost',
        'user' => 'test2user',
        'password' => '',
        'database' => '',
    ),

    'foo.com' => array(
        'server' => 'localhost',
        'user' => 'produser',
        'password' => '',
        'database' => '',
    ),

);

It appears that when accessing test1.foo.com, the foo.com environment is being loaded.

Looking at the docs again

When Craft is comparing your config keys with $_SERVER['SERVER_NAME'], it’s only looking for a partial match. So the environment key 'example.com' will also work if you’re accessing your site via www.example.com or any other subdomain. You could even just use the TLD if you’re feeling adventurous:

What's the best way to get around this issue, where we want subdomains for dev and test, when they are subdomains of the production domain.

Thanks.

0

As long as you have the more specific one at the top of your array like you do, it should work.

It looks like your using some custom (non-stock) Craft config logic judging from the $customDbConfig variable.

What happens if you echo $_SERVER['SERVER_NAME']; from the test1.foo.com domain?

If it's an exact match and it is still not selecting the right database, then I'd suspect your custom logic.

Strip all of that out to just Craft's default multi-environment config and see if it works that way.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.