Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-22T21:39:51.900Z
Answers.LastActivityDate: 2015-01-22T21:39:51.900Z
Answers.UserDisplayName: Russ Back
Body: <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>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-01-15T22:42:21.037Z
Comments.Text: 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?
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-01-15T22:51:18.367Z
Comments.Text: domain-a and domain-b both load. The 404s are Craft 404s both for the front-end and the CP.
Comments.UserDisplayName: Russ Back
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-01-15T22:53:21.863Z
Comments.Text: Can you add screenshot of the folder structure to the original post?
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-01-15T23:15:38.443Z
Comments.Text: 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.
Comments.UserDisplayName: Russ Back
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-01-15T23:46:28.017Z
Comments.Text: 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.
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-01-16T11:01:14.223Z
Comments.Text: 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.
Comments.UserDisplayName: Russ Back
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-01-16T17:50:17.563Z
Comments.Text: Ahh... those should probably all have a trailing slash on them.  Just updated the docs. Would you mind posting that as an official answer?
Comments.UserDisplayName: Brad Bell
Tags: <localization><multi-environment>
Title: Multiple databases, single codebase
ThreadText: # 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:
  
  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](https://i.sstatic.net/9MfWo.png)
  
  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;
  
  ```
  
  **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 username_0 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.
  
  
  ---
  
  