diff --git a/src/Umbraco.Web/Routing/DomainHelper.cs b/src/Umbraco.Web/Routing/DomainHelper.cs
index e62e0cb98a..a8ab38b4cc 100644
--- a/src/Umbraco.Web/Routing/DomainHelper.cs
+++ b/src/Umbraco.Web/Routing/DomainHelper.cs
@@ -51,9 +51,6 @@ namespace Umbraco.Web.Routing
/// The domain and its normalized uri, that best matches the current uri, else the first domain (if defaultToFirst is true), else null.
public static DomainAndUri DomainMatch(IEnumerable domains, Uri current, bool defaultToFirst)
{
- if (!domains.Any())
- return null;
-
// sanitize the list to have proper uris for comparison (scheme, path end with /)
// we need to end with / because example.com/foo cannot match example.com/foobar
// we need to order so example.com/foo matches before example.com/
@@ -64,6 +61,9 @@ namespace Umbraco.Web.Routing
.OrderByDescending(t => t.UriString)
.Select(t => new DomainAndUri { Domain = t.Domain, Uri = new Uri(t.UriString) });
+ if (!domainsAndUris.Any())
+ return null;
+
DomainAndUri domainAndUri;
if (current == null)
{