1

We have two sites that more or less share the share the same design, so we're thinking of having a single craft instance, but with DB config pointing to two separate DBs.

The idea being you can manage the content of both sites independently but not have to have the codebase (templates, plugins, frontend assets etc) duplicated across two installs.

Both sites would be localised so we'd have a number of URLs to configure.

Would this approach work?

One of the things I guess might be a problem is the license.key file?

EDIT>>>>

Given that I'm happy to keep the same templates across both sites but want to ensure the license works on both domains, I've tried the following:

  1. Configure domain-a.com to point to a webroot called ./domain-a/
  2. Configure domain-b.com to point to a webroot called ./domain-b/
  3. Copy the contents of Craft's ./public/ directory to the directories above
  4. In the index.php file in ./domain-a/ set the CRAFT_CONFIG_PATH PHP constant to point to ../craft/config-domain-a/
  5. In the index.php file in ./domain-b/ set the CRAFT_CONFIG_PATH PHP constant to point to ../craft/config-domain-b/
  6. Copy the contents of Craft's **./craft/config/* directory to the config directories above.

In theory, that should mean I can have a config - and therefore license.key file - for 2 domains that share the same codebase, including templates.

However the config seems to have an issue in that everything 404s. For example I've set the cpTrigger property in ./craft/config-domain-a/general.php and ./craft/config-domain-b/general.php to be something other than admin, which works fine until I make all the changes above.

EDIT >>>

Screenshot of more simple setup with config dir renamed to config-test:

Screenshot of folder structure

Contents of config's general.php file:

<?php

/**
 * General Configuration
 *
 * All of your system's general configuration settings go in here.
 * You can see a list of the default settings in craft/app/etc/config/defaults/general.php
 */

return array(

    '*' => array(
        'omitScriptNameInUrls' => true, 
        'cacheDuration' => 'P1W', 
        'siteUrl' => array(
            'en' => 'https://' . $_SERVER['SERVER_NAME'] . '/en/', 
            'es' => 'https://' . $_SERVER['SERVER_NAME'] . '/es/', 
            'fr' => 'https://' . $_SERVER['SERVER_NAME'] . '/fr/', 
            'de' => 'https://' . $_SERVER['SERVER_NAME'] . '/de/', 
            'it' => 'https://' . $_SERVER['SERVER_NAME'] . '/it/'
        ),
        'timezone' => 'Europe/London', 
        'allowAutoUpdates' => false, 
        'cpTrigger' => 'mgmt', 
        'rememberUsernameDuration' => false,
        'rememberedUserSessionDuration' => false,
        'useEmailAsUsername' => true
    ),

    'local.' => array(
        'devMode' => true, 
        'overridePhpSessionLocation' => false, 
        // 'translationDebugOutput' => true, 
        'allowAutoUpdates' => true, 
        'rememberUsernameDuration' => 'P1M',
        'rememberedUserSessionDuration' => false,
    )

);

The index.php file from public_html/ (through which we access the admin panel):

<?php

// Path to your craft/ folder
$craftPath = '../craft';

define('CRAFT_CONFIG_PATH', '../craft/config-test');

// Do not edit below this line
$path = rtrim($craftPath, '/').'/app/index.php';

if (!is_file($path))
{
    if (function_exists('http_response_code'))
    {
        http_response_code(503);
    }

    exit('Could not find your craft/ folder. Please ensure that <strong><code>$craftPath</code></strong> is set correctly in '.__FILE__);
}

require_once $path;

And finally the index.php from public_html/en/ (for the default English locale):

<?php

// Path to your craft/ folder
$craftPath = '../../craft';

// Tell Craft to serve the English content
define('CRAFT_LOCALE', 'en');

define('CRAFT_CONFIG_PATH', '../../craft/config-test');

// Do not edit below this line
$path = rtrim($craftPath, '/').'/app/index.php';

if (!is_file($path))
{
    if (function_exists('http_response_code'))
    {
        http_response_code(503);
    }

    exit('Could not find your craft/ folder. Please ensure that <strong><code>$craftPath</code></strong> is set correctly in '.__FILE__);
}

require_once $path;
7
  • Not sure I'm following your latest edit. cpTrigger change aside, are domain-a and domain-b loading? If not are they Apache or Craft 404 pages? And are they 404'ing on the front-end and the CP or just one or the other?
    – Brad Bell
    Commented Jan 15, 2015 at 22:42
  • domain-a and domain-b both load. The 404s are Craft 404s both for the front-end and the CP.
    – Russ Back
    Commented Jan 15, 2015 at 22:51
  • Can you add screenshot of the folder structure to the original post?
    – Brad Bell
    Commented Jan 15, 2015 at 22:53
  • Done. I've made it simpler - just renamed the ./craft/config/ directory to ./craft/config-test/ and added the PHP constant in ./public_html/index.php and ./public_html/en/index.php. Both produce Craft 404s and the tag that shows the site name in the top-left of the out-of-the-box index template is blank.
    – Russ Back
    Commented Jan 15, 2015 at 23:15
  • Yeah... you've got a lot going on here. Might be worth posting the contents of the 2 public .htaccess files. What I'd probably try to do is start with a more basic setup / fresh install, make sure that works and add the things back in one at a time until you see where things go wrong.
    – Brad Bell
    Commented Jan 15, 2015 at 23:46

1 Answer 1

3

Turns out it was simply a need to add a trailing slash to the CRAFT_CONFIG_PATH constant. I'd followed the docs - which have no trailing slash - and when I fixed that it works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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