<p>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.</p>

CC BY-SA 3.0
2015-01-22T21:39:51.900Z
2015-01-22T21:39:51.900Z
Russ Back
<p>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. </p>

<p>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.</p>

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

<p>Would this approach work?</p>

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

<p>EDIT>>>></p>

<p>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:</p>

<ol>
<li>Configure domain-a.com to point to a webroot called <strong>./domain-a/</strong></li>
<li>Configure domain-b.com to point to a webroot called <strong>./domain-b/</strong></li>
<li>Copy the contents of Craft's <strong>./public/</strong> directory to the directories above</li>
<li>In the index.php file in <strong>./domain-a/</strong> set the <strong>CRAFT_CONFIG_PATH</strong> PHP constant to point to <strong>../craft/config-domain-a/</strong></li>
<li>In the index.php file in .<strong>/domain-b/</strong> set the <strong>CRAFT_CONFIG_PATH</strong> PHP constant to point to <strong>../craft/config-domain-b/</strong></li>
<li>Copy the contents of Craft's **./craft/config/* directory to the config directories above.</li>
</ol>

<p>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. </p>

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

<p>EDIT >>></p>

<p>Screenshot of more simple setup with config dir renamed to <strong>config-test</strong>:</p>

<p><img src="https://i.sstatic.net/9MfWo.png" alt="Screenshot of folder structure"></p>

<p>Contents of config's general.php file:</p>

<pre><code>&lt;?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(

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

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

);
</code></pre>

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

<pre><code>&lt;?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 &lt;strong&gt;&lt;code&gt;$craftPath&lt;/code&gt;&lt;/strong&gt; is set correctly in '.__FILE__);
}

require_once $path;
</code></pre>

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

<pre><code>&lt;?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 &lt;strong&gt;&lt;code&gt;$craftPath&lt;/code&gt;&lt;/strong&gt; is set correctly in '.__FILE__);
}

require_once $path;
</code></pre>

CC BY-SA 3.0
2015-01-15T22:42:21.037Z
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
CC BY-SA 3.0
2015-01-15T22:51:18.367Z
domain-a and domain-b both load. The 404s are Craft 404s both for the front-end and the CP.
Russ Back
CC BY-SA 3.0
2015-01-15T22:53:21.863Z
Can you add screenshot of the folder structure to the original post?
Brad Bell
CC BY-SA 3.0
2015-01-15T23:15:38.443Z
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
CC BY-SA 3.0
2015-01-15T23:46:28.017Z
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
CC BY-SA 3.0
2015-01-16T11:01:14.223Z
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.
Russ Back
CC BY-SA 3.0
2015-01-16T17:50:17.563Z
Ahh... those should probably all have a trailing slash on them.  Just updated the docs. Would you mind posting that as an official answer?
Brad Bell
<localization><multi-environment>
Multiple databases, single codebase
# Multiple databases, single codebase

(Asked by: username_0 on 2015-01-15)

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:
 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):
$craftPath is set correctly in '.__FILE__);
}

require_once $path;

And finally the index.php from public_html/en/ (for the default English locale):
$craftPath is set correctly in '.__FILE__);
}

require_once $path;

**Tags:** localization, multi-environment

> **Comments:**
> **username_1**: 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?  
> **username_0**: domain-a and domain-b both load. The 404s are Craft 404s both for the front-end and the CP.  
> **username_1**: Can you add screenshot of the folder structure to the original post?  
> **username_0**: 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.  
> **username_1**: 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.  
> **username_0**: 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.  
> **username_1**: Ahh... those should probably all have a trailing slash on them.  Just updated the docs. Would you mind posting that as an official answer?  

---

## 1 answers

### Answer by username_0 on 2015-01-22. Score: 3 | Accepted answer

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.


---

