I have configured 3 different front pages for:
- mydomain.net (main domain)
- alfa.mydomain.net
- beta.mydomain.net

DNS returns same IP for mydomain.net and *.mydomain.net
httpd.conf defines virtual hosts alfa and beta

alfa.mydomain.net, beta.mydomain.net and mydomain.net
all point to the same front page (the main domain front page)

Comments

agentrickard’s picture

Category: support » bug

This is likely a bug, as this featue has not been heavily tested.

Let me be clear. You have these domains, plus the Domain Conf module turned on, with homepages set as:

- mydomain.net (main domain) == node (default)
- alfa.mydomain.net == example/path
- beta.mydomain.net == example/path/two

And all three home pages go to mydomain.net/?q=node.

Right?

skizzo’s picture

yes, namely (with pathauto):

alfa_page published-to domain alfa only
beta_page published-to domain beta only

- mydomain.net (main domain) == node
- alfa.mydomain.net == content/alfa_page
- beta.mydomain.net == content/beta_page

I saw the problem also without pathauto

agentrickard’s picture

Confirmed. This is not a pathauto problem. It seems that the $conf rewrite doesn't occur before the page determination is made.

Must investigate or remove this from the settings options.

agentrickard’s picture

Yes. The page assignment happens during Drupal bootstrap inside drupal_init_path().

So we won't be able to load these settings during hook_init() -- that's just too late in the process. We'll have to try loading them in the settings.php file.

This change to domain_conf_init() will pop the user to the correct page, but not the 'proper' home page.

function domain_conf_init() {
  global $_domain;
  // Load the domain-specific variables, if they exist.
  $data = array();
  $data = db_fetch_array(db_query("SELECT settings FROM {domain_conf} WHERE domain_id = %d", $_domain['domain_id']));
  if (!empty($data)) {
    global $conf;
    $settings = unserialize($data['settings']);
    // Overwrite the home page
    if ($settings['site_homepage'] && $_GET['q'] == variable_get('site_frontpage', 'node')) {
      drupal_goto($settings['site_frontpage']);
    }
    foreach ($settings as $key => $value) {
      $conf[$key] = $value;
    }
  }
}
agentrickard’s picture

Typo in last entry. Still, I don't think this is the 'right' solution.

function domain_conf_init() {
  global $_domain;
  // Load the domain-specific variables, if they exist.
  $data = array();
  $data = db_fetch_array(db_query("SELECT settings FROM {domain_conf} WHERE domain_id = %d", $_domain['domain_id']));
  if (!empty($data)) {
    global $conf;
    $settings = unserialize($data['settings']);
    // Overwrite the home page
    if ($settings['site_frontpage'] && $_GET['q'] == variable_get('site_frontpage', 'node')) {
      drupal_goto($settings['site_frontpage']);
    }
    foreach ($settings as $key => $value) {
      $conf[$key] = $value;
    }
  }
}
agentrickard’s picture

Likely we'll need to do this inside settings.php. See variable_init().

I had hoped to avoid this, but might need to bring back this file in some form.

agentrickard’s picture

See also conf_init()

agentrickard’s picture

We can likely do this in settings.php without the raw PHP/SQL code, by replicating this bootstrap phase:

    case DRUPAL_BOOTSTRAP_DATABASE:
      // Initialize the default database.
      require_once './includes/database.inc';
      db_set_active();
agentrickard’s picture

Actually, the first solution may work, since it may be that only the frontpage is an issue here. If we use drupal_goto() as shown and reset the homepage var, the Home breadcrumb trail does not appear, which seems acceptable.

agentrickard’s picture

The first solution does NOT work. We'll have to load this in settings.php.

agentrickard’s picture

Status: Active » Fixed

Fixed and committed to HEAD.

Note the new INSTALL.txt file in the domain_conf directory. These instructions must be followed for settigns overrides to work.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.