diff --git a/core/rebuild.php b/core/rebuild.php
index 9ddf054..f4107c2 100644
--- a/core/rebuild.php
+++ b/core/rebuild.php
@@ -29,6 +29,9 @@
 
   drupal_rebuild();
   drupal_set_message('Cache rebuild complete.');
+  header('Location: ' . $GLOBALS['base_url']);
+}
+else {
+  header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
+  print '<html><body><h1>Access denied</h2><p>Rebuild access is not enabled in settings.php.';
 }
-
-header('Location: ' . $GLOBALS['base_url']);
