function hosting_alias_automatic_aliases

7.x-3.x hosting_alias.module hosting_alias_automatic_aliases($url)

Generate a default set of aliases for the site based on the global options.

1 call to hosting_alias_automatic_aliases()
hosting_alias_insert in alias/hosting_alias.module
Save stored aliases for a new site.

File

alias/hosting_alias.module, line 499
Allow sites to have domain aliases that they can be accessed with.

Code

function hosting_alias_automatic_aliases($url) {
  $alias = array();
  if ($sub = variable_get('hosting_alias_subdomain', FALSE)) {
    if (!preg_match("/\." . preg_quote($sub, '/') . "$/", $url)) {
      $alias[] = str_replace(array('-', '.'), array('--', '-'), $url) . "." . trim($sub, ".");
    }
  }
  if (!preg_match('/^www\./', $url) && variable_get('hosting_alias_automatic_www', FALSE)) {
    $alias[] = "www." . $url;
  }
  elseif (preg_match('/^www\./', $url) && variable_get('hosting_alias_automatic_no_www', FALSE)) {
    $alias[] = str_replace("www.", "", $url);
  }
  return $alias;
}