diff --git a/core/SettingsPiwik.php b/core/SettingsPiwik.php
index <HASH>..<HASH> 100644
--- a/core/SettingsPiwik.php
+++ b/core/SettingsPiwik.php
@@ -198,7 +198,7 @@ class SettingsPiwik
             // if URL changes, always update the cache
             || $currentUrl != $url
         ) {
-            $host = Url::getHostFromUrl($url);
+            $host = Url::getHostFromUrl($currentUrl);
 
             if (strlen($currentUrl) >= strlen('http://a/')
                 && !Url::isLocalHost($host)) {
Improve detection of piwik/matomo URL (#<I>)

refs a couple of issues I think. Eg <URL>. If it checked whether the actual host is a local host, it would have updated it.