How do I safely get the internal path to the current site in a multisite setup? I'm working with a multisite Drupal 7 install with many sites. The site accepts both "www." and without via Apache. I'm developing a themes in /sites/all/themes which is used by many of these sites and I want something like this:

$apple_icon =  array(
    '#tag' =&gt; 'link',
    '#attributes' =&gt; array(
      'href' =&gt; '/' . path_to_site() . '/apple-touch-icon.png',
      'rel' =&gt; 'apple-touch-icon',
    ),
  );
  drupal_add_html_head($apple_icon, 'apple-touch-icon');


where path_to_site gives like /www/drupal7/sites/blah.com etc. depending on the site being used. I need this since each site will need a different icon.

I guess something like '/sites/' . $_SERVER['HTTP_HOST'] and then I can use symlink aliases for the "www." variant.

How can I do this properly?
You can use conf_path to get the path root to the current site - then append the rest of your path to that.


  Returns the configuration path based on the site's hostname, port, and
  pathname.


e.g:

$apple_icon =  array(
  '#tag' =&gt; 'link',
  '#attributes' =&gt; array(
    'href' =&gt; base_path() . conf_path() . '/apple-touch-icon.png',
    'rel' =&gt; 'apple-touch-icon',
  ),
);
drupal_add_html_head($apple_icon, 'apple-touch-icon');