diff --git a/login/index.php b/login/index.php
index a98af012c7a..e4293dc5ded 100644
--- a/login/index.php
+++ b/login/index.php
@@ -26,6 +26,12 @@
require('../config.php');
+// Try to prevent searching for sites that allow sign-up.
+if (!isset($CFG->additionalhtmlhead)) {
+ $CFG->additionalhtmlhead = '';
+}
+$CFG->additionalhtmlhead .= '';
+
redirect_if_major_upgrade_required();
$testsession = optional_param('testsession', 0, PARAM_INT); // test session works properly
diff --git a/login/signup.php b/login/signup.php
index 331f9ef4691..a35641ff4f3 100644
--- a/login/signup.php
+++ b/login/signup.php
@@ -26,6 +26,12 @@
require('../config.php');
+// Try to prevent searching for sites that allow sign-up.
+if (!isset($CFG->additionalhtmlhead)) {
+ $CFG->additionalhtmlhead = '';
+}
+$CFG->additionalhtmlhead .= '';
+
if (empty($CFG->registerauth)) {
print_error('notlocalisederrormessage', 'error', '', 'Sorry, you may not use this page.');
}