function drush_site_dir_lookup_from_hostname

8.0.x drush_site_dir_lookup_from_hostname($hostname, $site_root = NULL)
6.x drush_site_dir_lookup_from_hostname($hostname)
7.x drush_site_dir_lookup_from_hostname($hostname, $site_root = NULL)
master drush_site_dir_lookup_from_hostname($hostname, $site_root = NULL)

Lookup a site's directory via the sites.php file given a hostname.


$hostname: The hostname of a site. May be converted from URI.

Return value

$dir The directory associated with that hostname or FALSE if not found.

1 call to drush_site_dir_lookup_from_hostname()
drush_sitealias_uri_to_site_dir in includes/
Convert from a URI to a site directory.


includes/, line 284
Functions used by drush to query the environment and setting the current configuration.


function drush_site_dir_lookup_from_hostname($hostname) {
  $site_root = drush_get_context('DRUSH_SELECTED_DRUPAL_ROOT');
  if (file_exists($site_root . '/sites/sites.php')) {
    $sites = array();
    // This will overwrite $sites with the desired mappings.
    include ($site_root . '/sites/sites.php');
    return isset($sites[$hostname]) ? $sites[$hostname] : FALSE;
  else {
    return FALSE;