settings_domain_prefix.inc does not include the logic for removing the www prefix from a hostname -- as controlled by the settings for the main module.

And settings_domain_conf.inc needs to be tested to ensure that featuer works correctly, since the variables array may not be available that early in the bootstrap process.

THis applies to 5.x and 6.x

Comments

agentrickard’s picture

It may also be that the logic in domain_init() is incorrect. Specifically.

  // Strip the www. off the subdomain, if required.
  if (variable_get('domain_www', 0)) {
    $_subdomain = str_replace('www.', '', $_subdomain);
  }
  // Lookup the active domain against our allowed hosts record.
  $data = db_fetch_array(db_query("SELECT domain_id FROM {domain} WHERE subdomain = '%s'", $_subdomain));
  // Get the domain data.
  $_domain = domain_lookup($data['domain_id']);
  // If return is -1, then the DNS didn't match anything, so use defaults.
  if ($_domain == -1) {
    $_domain = domain_default();
  }
  // For Domain User, we check the validity of accounts, so the 'valid' flag must be TRUE.
  // If this check fails, we send users to the default site homepage.
  if (!$_domain['valid'] && !user_access('administer domains')) {
    $_domain = domain_default();
    drupal_goto($_domain['path']);
  }
fool2’s picture

It needs to be processed before domain_prefix.... this is breaking my sites because we use url aliases as a prefixed table.

I don't think variable_get() is available in settings_domain_prefix.inc-- meaning this is unfixable without adding a config line to settings.php. Since we already have to modify settings.php for it anyway, this shouldn't be a problem. hook_init() just isn't going to cut it though

I also think that even if we COULD use variable_get in settings, there would be the opportunity for a logical loop because the variable table could depend on the domain prefix, which would depend on the variable table and so on

I couldn't see any problems with the code you've referenced above.

agentrickard’s picture

Right. The other fix is to put a redirect inside domain_init() that sends people from www.example.com to example.com. This approach is the simpler fix, since it only requires one change -- and it is one that I control.

agentrickard’s picture

Status: Active » Fixed

Fixed in 5.x.1.4 and 6.x

Anonymous’s picture

Status: Fixed » Closed (fixed)

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