diff --git a/webclient/login/login-controller.js b/webclient/login/login-controller.js
index 2b91926954b3502390eb91ac6e53606c8a2172c7..af9a61f0f0ff5ff597a10e2d00d2199e792bcacd 100644
--- a/webclient/login/login-controller.js
+++ b/webclient/login/login-controller.js
@@ -7,7 +7,10 @@ angular.module('LoginController', ['matrixService'])
     // Assume that this is hosted on the home server, in which case the URL
     // contains the home server.
     var hs_url = $location.protocol() + "://" + $location.host();
-    if ($location.port()) {
+    if ($location.port() &&
+        !($location.protocol() === "http" && $location.port() === 80) &&
+        !($location.protocol() === "https" && $location.port() === 443))
+    {
         hs_url += ":" + $location.port();
     }
     var example_domain = $location.host();
diff --git a/webclient/login/register-controller.js b/webclient/login/register-controller.js
index 6c1bfd632abc6ae6748ac6bfe7b56a7bbb0f1d4e..d4fb9add7091434f901438a89063ce2620a821b1 100644
--- a/webclient/login/register-controller.js
+++ b/webclient/login/register-controller.js
@@ -8,7 +8,10 @@ angular.module('RegisterController', ['matrixService'])
     // Assume that this is hosted on the home server, in which case the URL
     // contains the home server.
     var hs_url = $location.protocol() + "://" + $location.host();
-    if ($location.port()) {
+    if ($location.port() &&
+        !($location.protocol() === "http" && $location.port() === 80) &&
+        !($location.protocol() === "https" && $location.port() === 443))
+    {
         hs_url += ":" + $location.port();
     }