1

Given a multi site setup (domain1.com, domain2.com) that also uses multiple environments (dev, staging, production) - how would one configure one of the sites to be turned off in the production environment?

I'm currently trying the following.

return [
    // Global settings
    '*' => [
        // removed for clarity
    ],


    'dev' => [
        'devMode' => true,
        'isSystemLive' => [
            'domain1.com' => true,
            'domain2.com' => false
        ]
    ],

    // Staging environment settings
    'staging' => [
        'devMode' => true,
        'isSystemLive' => [
            'domain1.com' => true,
            'domain2.com' => false
        ]
    ],

    // Production environment settings
    'production' => [
        'devMode' => false,
        'isSystemLive' => [
            'domain1.com' => true,
            'domain2.com' => false
        ]
    ]
];

Which I would have expected to have domain2.com turned off but domain1.com remains on. However, both sites are on.

I have also tried rearranging the config using the following structure (stripped back for brevity)

return [
    'domain1.com' => [
        '*' => [
            // default for domain1
        ],

        'dev' => [
            'isSystemLive' => true
        ],

        'staging' => [
            'isSystemLive' => true
        ],

        'production' => [
            'isSystemLive' => true
        ]
    ],

    'domain2.com' => [
        '*' => [
            // default for domain2
        ],

        'dev' => [
            'isSystemLive' => false
        ],

        'staging' => [
            'isSystemLive' => false
        ],

        'production' => [
            'isSystemLive' => false
        ]
    ],
]

But this also doesn't work.

So how should I specify different multi-environment configs for each site?

2

The isSystemLive config setting isn't multi-site aware. It sets the entire Craft installation on or off, rather than per site, so you'll need to find a different method to disable domain2.com on the production server.

Untested, but you could try to set the baseUrl for domain2.com to an empty string on production and see if that works.

  • 1
    Just discovered this while submitting a Feature request. github.com/craftcms/cms/issues/3005 Thanks! – foamcow Jun 5 at 13:35
  • For the record, I turned off "This site has a base url" and set the site url to a blank string as suggested. Not sure – foamcow Jun 5 at 13:36
1

If you are running Apache, you could set your ENVIRONMENT variable in your <VirtualHost> directive using SetEnv ENVIRONMENT "domain2" then have a section:

'domain2' => [
   'isSystemLive' => false
],

In your config/general.php.

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.