diff --git a/config/global.ini.php b/config/global.ini.php
index c8eb24598133886fcee26d5a3b38e942a6559c4f..8722c0e5d996b46cc5af6096a2094c7c04ff0d15 100644
--- a/config/global.ini.php
+++ b/config/global.ini.php
@@ -358,6 +358,11 @@ enable_trusted_host_check = 1
 ;trusted_hosts[] = example.com
 ;trusted_hosts[] = stats.example.com
 
+; If you use this Piwik instance over multiple hostnames, Piwik will need to know
+; a unique instance_id for this instance, so that Piwik can serve the right custom logo and tmp/* assets,
+; independantly of the hostname Piwik is currently running under.
+; instance_id = stats.example.com
+
 ; The release server is an essential part of the Piwik infrastructure/ecosystem
 ; to provide the latest software version.
 latest_version_url = http://builds.piwik.org/latest.zip
diff --git a/core/AssetManager.php b/core/AssetManager.php
index 90185a43f3c92f54b9de7691525f2108244e5077..4a0de2e3b065d417e3476c4aac204bdf4f76a2b7 100644
--- a/core/AssetManager.php
+++ b/core/AssetManager.php
@@ -253,7 +253,7 @@ class AssetManager extends Singleton
     public function getAssetDirectory()
     {
         $mergedFileDirectory = PIWIK_USER_PATH . "/tmp/assets";
-        $mergedFileDirectory = SettingsPiwik::rewriteTmpPathWithHostname($mergedFileDirectory);
+        $mergedFileDirectory = SettingsPiwik::rewriteTmpPathWithInstanceId($mergedFileDirectory);
 
         if (!is_dir($mergedFileDirectory)) {
             Filesystem::mkdir($mergedFileDirectory);
diff --git a/core/CacheFile.php b/core/CacheFile.php
index 043770b3db6e1d407647fbeb43a98948a3708d43..5d9000332f72b35cac07973c9c6a8f5d93904227 100644
--- a/core/CacheFile.php
+++ b/core/CacheFile.php
@@ -43,7 +43,7 @@ class CacheFile
     public function __construct($directory, $timeToLiveInSeconds = 300)
     {
         $cachePath = PIWIK_USER_PATH . '/tmp/cache/' . $directory . '/';
-        $this->cachePath = SettingsPiwik::rewriteTmpPathWithHostname($cachePath);
+        $this->cachePath = SettingsPiwik::rewriteTmpPathWithInstanceId($cachePath);
 
         if ($timeToLiveInSeconds < self::MINIMUM_TTL) {
             $timeToLiveInSeconds = self::MINIMUM_TTL;
diff --git a/core/CliMulti.php b/core/CliMulti.php
index cb53c4ed4a2b4f190c7f501e5909150a7dea78a9..740528ecb398a4b134f26314becc37e6f5c6f443 100644
--- a/core/CliMulti.php
+++ b/core/CliMulti.php
@@ -203,7 +203,7 @@ class CliMulti {
     public static function getTmpPath()
     {
         $dir = PIWIK_INCLUDE_PATH . '/tmp/climulti';
-        return SettingsPiwik::rewriteTmpPathWithHostname($dir);
+        return SettingsPiwik::rewriteTmpPathWithInstanceId($dir);
     }
 
     private function findPhpBinary()
diff --git a/core/Db/BatchInsert.php b/core/Db/BatchInsert.php
index 659954d06a67e3f67255c31913b4275672ce8a71..3a05e516d66fa6494d10c968034e04192dba3f78 100644
--- a/core/Db/BatchInsert.php
+++ b/core/Db/BatchInsert.php
@@ -59,7 +59,7 @@ class BatchInsert
     public static function tableInsertBatch($tableName, $fields, $values, $throwException = false)
     {
         $filePath = PIWIK_USER_PATH . '/tmp/assets/' . $tableName . '-' . Common::generateUniqId() . '.csv';
-        $filePath = SettingsPiwik::rewriteTmpPathWithHostname($filePath);
+        $filePath = SettingsPiwik::rewriteTmpPathWithInstanceId($filePath);
 
         $loadDataInfileEnabled = Config::getInstance()->General['enable_load_data_infile'];
 
diff --git a/core/Filechecks.php b/core/Filechecks.php
index 52cb995bad8f02c54427650cf85eb003339bb546..7bbf0f116294b64adbb23e4c1cb0b26e3b0b2711 100644
--- a/core/Filechecks.php
+++ b/core/Filechecks.php
@@ -44,7 +44,7 @@ class Filechecks
             }
 
             if(strpos($directoryToCheck, '/tmp/') !== false) {
-                $directoryToCheck = SettingsPiwik::rewriteTmpPathWithHostname($directoryToCheck);
+                $directoryToCheck = SettingsPiwik::rewriteTmpPathWithInstanceId($directoryToCheck);
             }
 
             Filesystem::mkdir($directoryToCheck);
diff --git a/core/Log.php b/core/Log.php
index 09d548a7f088a79f2ca4f9ff88f026b924caf6e6..ab4093cb5f6d8a9f2bf6f1773d56e8290dc3ac4a 100644
--- a/core/Log.php
+++ b/core/Log.php
@@ -323,7 +323,7 @@ class Log extends Singleton
         ) {
             $logPath = PIWIK_USER_PATH . DIRECTORY_SEPARATOR . $logPath;
         }
-        $logPath = SettingsPiwik::rewriteTmpPathWithHostname($logPath);
+        $logPath = SettingsPiwik::rewriteTmpPathWithInstanceId($logPath);
         if (is_dir($logPath)) {
             $logPath .= '/piwik.log';
         }
diff --git a/core/ReportRenderer.php b/core/ReportRenderer.php
index 4634f9197c891c38e3d1c54f256e3a55cdda6e9c..42a5f725700c34358c88df3cf3d75e823c4a7b85 100644
--- a/core/ReportRenderer.php
+++ b/core/ReportRenderer.php
@@ -144,7 +144,7 @@ abstract class ReportRenderer
     protected static function getOutputPath($filename)
     {
         $outputFilename = PIWIK_USER_PATH . '/tmp/assets/' . $filename;
-        $outputFilename = SettingsPiwik::rewriteTmpPathWithHostname($outputFilename);
+        $outputFilename = SettingsPiwik::rewriteTmpPathWithInstanceId($outputFilename);
 
         @chmod($outputFilename, 0600);
         @unlink($outputFilename);
diff --git a/core/Session.php b/core/Session.php
index b2e91f7e68fd313b9c19e9f2511ea940c0ce6702..7cf8ab4f9ca143f506fecce909db7f65c1b02b49 100644
--- a/core/Session.php
+++ b/core/Session.php
@@ -122,7 +122,7 @@ class Session extends Zend_Session
             }
 
             $pathToSessions = Filechecks::getErrorMessageMissingPermissions(Filesystem::getPathToPiwikRoot() . '/tmp/sessions/');
-            $pathToSessions = SettingsPiwik::rewriteTmpPathWithHostname($pathToSessions);
+            $pathToSessions = SettingsPiwik::rewriteTmpPathWithInstanceId($pathToSessions);
             $message = sprintf("Error: %s %s %s\n<pre>Debug: the original error was \n%s</pre>",
                 Piwik::translate('General_ExceptionUnableToStartSession'),
                 $pathToSessions,
@@ -142,7 +142,7 @@ class Session extends Zend_Session
     public static function getSessionsDirectory()
     {
         $path = PIWIK_USER_PATH . '/tmp/sessions';
-        return SettingsPiwik::rewriteTmpPathWithHostname($path);
+        return SettingsPiwik::rewriteTmpPathWithInstanceId($path);
     }
 
     public static function close()
diff --git a/core/SettingsPiwik.php b/core/SettingsPiwik.php
index 723ea065dc58ea29829a4e332d93bf712054a9c1..61b27607e39bd9e658fd57464f19e9e99f26f4bc 100644
--- a/core/SettingsPiwik.php
+++ b/core/SettingsPiwik.php
@@ -256,16 +256,24 @@ class SettingsPiwik
         return $result;
     }
 
+    /**
+     * @deprecated Use SettingsPiwik::rewriteTmpPathWithInstanceId instead
+     */
+    public static function rewriteTmpPathWithHostname($path)
+    {
+        return self::rewriteTmpPathWithInstanceId($path);
+    }
+
     /**
      * If Piwik uses per-domain config file, also make tmp/ folder per-domain
      * @param $path
      * @return string
      * @throws \Exception
      */
-    public static function rewriteTmpPathWithHostname($path)
+    public static function rewriteTmpPathWithInstanceId($path)
     {
         $tmp = '/tmp/';
-        $path = self::rewritePathAppendHostname($path, $tmp);
+        $path = self::rewritePathAppendPiwikInstanceId($path, $tmp);
         return $path;
     }
 
@@ -274,10 +282,10 @@ class SettingsPiwik
      * @param $path
      * @return mixed
      */
-    public static function rewriteMiscUserPathWithHostname($path)
+    public static function rewriteMiscUserPathWithInstanceId($path)
     {
         $tmp = 'misc/user/';
-        $path = self::rewritePathAppendHostname($path, $tmp);
+        $path = self::rewritePathAppendPiwikInstanceId($path, $tmp);
         return $path;
     }
 
@@ -345,10 +353,10 @@ class SettingsPiwik
      * @return mixed
      * @throws \Exception
      */
-    protected static function rewritePathAppendHostname($pathToRewrite, $leadingPathToAppendHostnameTo)
+    protected static function rewritePathAppendPiwikInstanceId($pathToRewrite, $leadingPathToAppendHostnameTo)
     {
-        $hostname = self::getConfigHostname();
-        if (empty($hostname)) {
+        $instanceId = self::getPiwikInstanceId();
+        if (empty($instanceId)) {
             return $pathToRewrite;
         }
 
@@ -356,7 +364,7 @@ class SettingsPiwik
             throw new Exception("The path $pathToRewrite was expected to contain the string  $leadingPathToAppendHostnameTo");
         }
 
-        $tmpToReplace = $leadingPathToAppendHostnameTo . $hostname . '/';
+        $tmpToReplace = $leadingPathToAppendHostnameTo . $instanceId . '/';
 
         // replace only the latest occurrence (in case path contains twice /tmp)
         $pathToRewrite = substr_replace($pathToRewrite, $tmpToReplace, $posTmp, strlen($leadingPathToAppendHostnameTo));
@@ -364,16 +372,31 @@ class SettingsPiwik
     }
 
     /**
-     * @return bool|string
+     * @throws \Exception
+     * @return string or False if not set
      */
-    protected static function getConfigHostname()
+    protected static function getPiwikInstanceId()
     {
+        // until Piwik is installed, we use hostname as instance_id
         if(!self::isPiwikInstalled()
             && Common::isPhpCliMode()) {
             // enterprise:install use case
             return Config::getHostname();
         }
-        return Config::getInstance()->getConfigHostnameIfSet();
+
+        $instanceId = @Config::getInstance()->General['instance_id'];
+        if(!empty($instanceId)) {
+            return $instanceId;
+        }
+
+        // Backward compatbility, in case the instance_id is not in the config file yet
+        $configHostname = Config::getInstance()->getConfigHostnameIfSet();
+        if(!empty($configHostname)) {
+            return $configHostname;
+        }
+
+        // do not rewrite the path as Piwik uses the standard config.ini.php file
+        return false;
     }
 
     /**
diff --git a/core/Twig.php b/core/Twig.php
index 6b628c9be782d469186e5f980be580cfb271f929..8c5ce8a2ef614abb38075629815504fe23196059 100755
--- a/core/Twig.php
+++ b/core/Twig.php
@@ -60,7 +60,7 @@ class Twig
 
         // Create new Twig Environment and set cache dir
         $templatesCompiledPath = PIWIK_USER_PATH . '/tmp/templates_c';
-        $templatesCompiledPath = SettingsPiwik::rewriteTmpPathWithHostname($templatesCompiledPath);
+        $templatesCompiledPath = SettingsPiwik::rewriteTmpPathWithInstanceId($templatesCompiledPath);
 
         $this->twig = new Twig_Environment($chainLoader,
             array(
diff --git a/core/Url.php b/core/Url.php
index 7d5d05d08dabfc922ba923e15546af7b13308511..fbcd379df5756aeeb888b0729b78e8b24ac59ad0 100644
--- a/core/Url.php
+++ b/core/Url.php
@@ -557,12 +557,7 @@ class Url
 
     public static function getTrustedHosts()
     {
-        $trustedHosts = self::getTrustedHostsFromConfig();
-
-        /* used by Piwik PRO */
-        Piwik::postEvent('Url.filterTrustedHosts', array(&$trustedHosts));
-
-        return $trustedHosts;
+        return self::getTrustedHostsFromConfig();
     }
 
     /**
diff --git a/plugins/CoreAdminHome/CustomLogo.php b/plugins/CoreAdminHome/CustomLogo.php
index f4c95c49b3cacfde08a73396650e645b7c3d458a..7f543973c33016ad6076362b8228fbc56c3ca034 100644
--- a/plugins/CoreAdminHome/CustomLogo.php
+++ b/plugins/CoreAdminHome/CustomLogo.php
@@ -147,7 +147,7 @@ class CustomLogo
 
     protected static function rewritePath($path)
     {
-        return SettingsPiwik::rewriteMiscUserPathWithHostname($path);
+        return SettingsPiwik::rewriteMiscUserPathWithInstanceId($path);
     }
 
     public function copyUploadedLogoToFilesystem()
diff --git a/plugins/CoreConsole/Commands/WatchLog.php b/plugins/CoreConsole/Commands/WatchLog.php
index ce89fa85e4337f7473bb095bc4011a159b3b1744..fc06dae46a98f7d9a1c1d015a2213dd0dda17457 100644
--- a/plugins/CoreConsole/Commands/WatchLog.php
+++ b/plugins/CoreConsole/Commands/WatchLog.php
@@ -27,7 +27,7 @@ class WatchLog extends ConsoleCommand
     protected function execute(InputInterface $input, OutputInterface $output)
     {
         $path = sprintf('%s/tmp/logs/', PIWIK_DOCUMENT_ROOT);
-        $path = SettingsPiwik::rewriteTmpPathWithHostname($path);
+        $path = SettingsPiwik::rewriteTmpPathWithInstanceId($path);
         $cmd = sprintf('tail -f %s*.log', $path);
 
         $output->writeln('Executing command: ' . $cmd);
diff --git a/plugins/CorePluginsAdmin/PluginInstaller.php b/plugins/CorePluginsAdmin/PluginInstaller.php
index 434332b81fcc2d27e85d7c5f48fed52b105cde62..a3ecdecff2ebe738a1fbe898cb52139f5453c16e 100644
--- a/plugins/CorePluginsAdmin/PluginInstaller.php
+++ b/plugins/CorePluginsAdmin/PluginInstaller.php
@@ -35,8 +35,8 @@ class PluginInstaller
         $tmpPluginZip = PIWIK_USER_PATH . self::PATH_TO_DOWNLOAD . $this->pluginName . '.zip';
         $tmpPluginFolder = PIWIK_USER_PATH . self::PATH_TO_DOWNLOAD . $this->pluginName;
 
-        $tmpPluginZip = SettingsPiwik::rewriteTmpPathWithHostname($tmpPluginZip);
-        $tmpPluginFolder = SettingsPiwik::rewriteTmpPathWithHostname($tmpPluginFolder);
+        $tmpPluginZip = SettingsPiwik::rewriteTmpPathWithInstanceId($tmpPluginZip);
+        $tmpPluginFolder = SettingsPiwik::rewriteTmpPathWithInstanceId($tmpPluginFolder);
 
         try {
             $this->makeSureFoldersAreWritable();
@@ -63,7 +63,7 @@ class PluginInstaller
     public function installOrUpdatePluginFromFile($pathToZip)
     {
         $tmpPluginFolder = PIWIK_USER_PATH . self::PATH_TO_DOWNLOAD . $this->pluginName;
-        $tmpPluginFolder = SettingsPiwik::rewriteTmpPathWithHostname($tmpPluginFolder);
+        $tmpPluginFolder = SettingsPiwik::rewriteTmpPathWithInstanceId($tmpPluginFolder);
 
         try {
             $this->makeSureFoldersAreWritable();
diff --git a/plugins/CoreUpdater/Controller.php b/plugins/CoreUpdater/Controller.php
index 11c2d160cb90a09f22cf1f148e8316735f3d6154..126701f5405f32c7eff830cc01b1f611e31b1b97 100644
--- a/plugins/CoreUpdater/Controller.php
+++ b/plugins/CoreUpdater/Controller.php
@@ -179,7 +179,7 @@ class Controller extends \Piwik\Plugin\Controller
     private function oneClick_Download()
     {
         $pathPiwikZip = PIWIK_USER_PATH . self::PATH_TO_EXTRACT_LATEST_VERSION . 'latest.zip';
-        $this->pathPiwikZip = SettingsPiwik::rewriteTmpPathWithHostname($pathPiwikZip);
+        $this->pathPiwikZip = SettingsPiwik::rewriteTmpPathWithInstanceId($pathPiwikZip);
 
         Filechecks::dieIfDirectoriesNotWritable(array(self::PATH_TO_EXTRACT_LATEST_VERSION));
 
@@ -192,7 +192,7 @@ class Controller extends \Piwik\Plugin\Controller
     private function oneClick_Unpack()
     {
         $pathExtracted = PIWIK_USER_PATH . self::PATH_TO_EXTRACT_LATEST_VERSION;
-        $pathExtracted = SettingsPiwik::rewriteTmpPathWithHostname($pathExtracted);
+        $pathExtracted = SettingsPiwik::rewriteTmpPathWithInstanceId($pathExtracted);
 
         $this->pathRootExtractedPiwik = $pathExtracted . 'piwik';
 
diff --git a/plugins/ImageGraph/StaticGraph.php b/plugins/ImageGraph/StaticGraph.php
index 10c20260db156b52a066fa5e59c118ce0f6b1a95..71d08162e2f53e7693c03c8e06cc23ac1cdc8ebd 100644
--- a/plugins/ImageGraph/StaticGraph.php
+++ b/plugins/ImageGraph/StaticGraph.php
@@ -240,7 +240,7 @@ abstract class StaticGraph
     protected static function getOutputPath($filename)
     {
         $outputFilename = PIWIK_USER_PATH . '/tmp/assets/' . $filename;
-        $outputFilename = SettingsPiwik::rewriteTmpPathWithHostname($outputFilename);
+        $outputFilename = SettingsPiwik::rewriteTmpPathWithInstanceId($outputFilename);
 
         @chmod($outputFilename, 0600);
         @unlink($outputFilename);
diff --git a/plugins/ScheduledReports/config/tcpdf_config.php b/plugins/ScheduledReports/config/tcpdf_config.php
index 9d5317156c425224ac2295e96cc4294c1f4f8938..e0847609492b12e6a98649d0a34da5f6a2d28103 100644
--- a/plugins/ScheduledReports/config/tcpdf_config.php
+++ b/plugins/ScheduledReports/config/tcpdf_config.php
@@ -15,7 +15,7 @@
 define('K_PATH_MAIN', PIWIK_INCLUDE_PATH . '/libs/tcpdf/');
 
 $pathTmpTCPDF = PIWIK_USER_PATH . '/tmp/tcpdf/';
-$pathTmpTCPDF = \Piwik\SettingsPiwik::rewriteTmpPathWithHostname($pathTmpTCPDF);
+$pathTmpTCPDF = \Piwik\SettingsPiwik::rewriteTmpPathWithInstanceId($pathTmpTCPDF);
 
 define('K_PATH_CACHE', $pathTmpTCPDF);
 define('K_PATH_IMAGES', $pathTmpTCPDF);
diff --git a/tests/PHPUnit/Core/DeprecatedMethodsTest.php b/tests/PHPUnit/Core/DeprecatedMethodsTest.php
index 148b3489a89d05eb31046b354f1b1d2154f89fe2..e3c7336e9398d88729081fb722885b26317f00a2 100644
--- a/tests/PHPUnit/Core/DeprecatedMethodsTest.php
+++ b/tests/PHPUnit/Core/DeprecatedMethodsTest.php
@@ -22,6 +22,9 @@ class DeprecatedMethodsTest extends PHPUnit_Framework_TestCase
 
         $validTill = '2014-10-01';
         $this->assertDeprecatedMethodIsRemoved('\Piwik\Config', 'getConfigSuperUserForBackwardCompatibility', $validTill);
+
+        $validTill = '2014-10-15';
+        $this->assertDeprecatedMethodIsRemoved('\Piwik\SettingsPiwik', 'rewriteTmpPathWithHostname', $validTill);
     }
 
     private function assertDeprecatedMethodIsRemoved($className, $method, $removalDate)
diff --git a/tests/PHPUnit/Integration/Core/LogTest.php b/tests/PHPUnit/Integration/Core/LogTest.php
index a7c76aa078efb630401c692a084411a284724239..5fada09e1a57190336e9903ae2f423bb7953bac6 100644
--- a/tests/PHPUnit/Integration/Core/LogTest.php
+++ b/tests/PHPUnit/Integration/Core/LogTest.php
@@ -270,7 +270,7 @@ dummy backtrace'
     public static function getLogFileLocation()
     {
         $path = self::getDefaultLogFileLocation();
-        $path = \Piwik\SettingsPiwik::rewriteTmpPathWithHostname($path);
+        $path = \Piwik\SettingsPiwik::rewriteTmpPathWithInstanceId($path);
         return $path;
     }