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:
- Configure domain-a.com to point to a webroot called ./domain-a/
- Configure domain-b.com to point to a webroot called ./domain-b/
- Copy the contents of Craft's ./public/ directory to the directories above
- In the index.php file in ./domain-a/ set the CRAFT_CONFIG_PATH PHP constant to point to ../craft/config-domain-a/
- In the index.php file in ./domain-b/ set the CRAFT_CONFIG_PATH PHP constant to point to ../craft/config-domain-b/
- 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:
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;