diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc
index 6dfc270..358ed50 100644
--- a/core/includes/install.core.inc
+++ b/core/includes/install.core.inc
@@ -250,7 +250,7 @@ function install_state_defaults() {
  *   An array of information about the current installation state. This is
  *   modified with information gleaned from the beginning of the page request.
  */
-function install_begin_request(&$install_state) {
+function install_begin_request(&$install_state, $config_verified = NULL) {
   // A request object from the HTTPFoundation to tell us about the request.
   $request = Request::createFromGlobals();
 
@@ -336,7 +336,12 @@ function install_begin_request(&$install_state) {
   \Drupal::setContainer($container);
 
   // Determine whether base system services are ready to operate.
-  $install_state['config_verified'] = install_verify_config_directory(CONFIG_ACTIVE_DIRECTORY) && install_verify_config_directory(CONFIG_STAGING_DIRECTORY);
+  if (isset($config_verified)) {
+    $install_state['config_verified'] = $config_verified;
+  }
+  else {
+    $install_state['config_verified'] = install_verify_config_directory(CONFIG_ACTIVE_DIRECTORY) && install_verify_config_directory(CONFIG_STAGING_DIRECTORY);
+  }
   $install_state['database_verified'] = install_verify_database_settings();
   $install_state['settings_verified'] = $install_state['config_verified'] && $install_state['database_verified'];
 
diff --git a/core/includes/theme.maintenance.inc b/core/includes/theme.maintenance.inc
index 96dcd2f..7b40ce3 100644
--- a/core/includes/theme.maintenance.inc
+++ b/core/includes/theme.maintenance.inc
@@ -192,3 +192,39 @@ function theme_authorize_message($variables) {
   }
   return $item;
 }
+
+/**
+ * Renders a 403 access denied page for update.php.
+ *
+ * @return
+ *   Rendered HTML warning with 403 status.
+ */
+function maintenance_access_denied_page($script_name = 'update.php', $settings_name = 'update_free_access', $login = TRUE, $postfix = '') {
+  drupal_add_http_header('Status', '403 Forbidden');
+  header(\Drupal::request()->server->get('SERVER_PROTOCOL') . ' 403 Forbidden');
+  watchdog('access denied', 'update.php', NULL, WATCHDOG_WARNING);
+  drupal_set_title('Access denied');
+  $output = '<p>Access denied. You are not authorized to access this page.';
+  if ($login) {
+    $output .= 'Log in using either an account with the <em>administer software updates</em> permission or the site maintenance account (the account you created during installation). If you cannot log in, you will have to';
+  }
+  else {
+    $output .= 'You need to ';
+  }
+  $output .= 'edit <code>settings.php</code> to bypass this access check. To do this:</p>
+<ol>
+ <li>With a text editor find the settings.php file on your system. From the main Drupal directory that you installed all the files into, go to <code>sites/your_site_name</code> if such directory exists, or else to <code>sites/default</code> which applies otherwise.</li>
+ <li>There is a line inside your settings.php file that says <code>$settings[\'' . $settings_name . '\'] = FALSE;</code>. Change it to <code>$settings[\'' . $settings_name . '\'] = TRUE;</code>.</li>
+ <li>As soon as the ' . $script_name . ' script is done, you must change the settings.php file back to its original form with <code>$settings[\'' . $settings_name .'\'] = FALSE;</code>.</li>
+ <li>
+ ';
+  if ($login) {
+    $output .= 'To avoid having this problem in the future, remember to log in to your website using either an account with the <em>administer software updates</em> permission or the site maintenance account (the account you created during installation) before you backup your database at the beginning of the update process.';
+  }
+  if ($postfix) {
+    $output .= $postfix;
+  }
+  $output .= '</li></ol>';
+  return $output;
+}
+
diff --git a/core/rebuild.php b/core/rebuild.php
index 1b94601..937cf3b 100644
--- a/core/rebuild.php
+++ b/core/rebuild.php
@@ -16,7 +16,9 @@
 chdir('..');
 
 require_once dirname(__DIR__) . '/core/includes/bootstrap.inc';
-require_once dirname(__DIR__) . '/core/includes/utility.inc';
+require_once DRUPAL_ROOT . '/core/includes/utility.inc';
+
+define('MAINTENANCE_MODE', 'update');
 
 drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION);
 
@@ -28,6 +30,21 @@
 
   drupal_rebuild();
   drupal_set_message('Cache rebuild complete.');
+  header('Location: ' . $GLOBALS['base_url']);
+}
+else {
+  require_once DRUPAL_ROOT . '/core/includes/install.core.inc';
+  require_once DRUPAL_ROOT . '/core/includes/update.inc';
+  $install_state = array('interactive' => FALSE) + install_state_defaults();
+  install_begin_request($install_state, FALSE);
+  $output = maintenance_access_denied_page('rebuild.php', 'rebuild_access', FALSE, 'Read more information, see the <a href="https://drupal.org/documentation/rebuild">handbook</a>.');
+  drupal_add_http_header('Content-Type', 'text/html; charset=utf-8');
+  $maintenance_page = array(
+    '#theme' => 'maintenance_page',
+    '#content' => $output,
+    '#show_messages' => FALSE,
+  );
+  print drupal_render($maintenance_page);
+
 }
 
-header('Location: ' . $GLOBALS['base_url']);
diff --git a/core/update.php b/core/update.php
index 527a703..3f9f779 100644
--- a/core/update.php
+++ b/core/update.php
@@ -215,26 +215,6 @@ function update_info_page() {
 }
 
 /**
- * Renders a 403 access denied page for update.php.
- *
- * @return
- *   Rendered HTML warning with 403 status.
- */
-function update_access_denied_page() {
-  drupal_add_http_header('Status', '403 Forbidden');
-  header(\Drupal::request()->server->get('SERVER_PROTOCOL') . ' 403 Forbidden');
-  watchdog('access denied', 'update.php', NULL, WATCHDOG_WARNING);
-  drupal_set_title('Access denied');
-  return '<p>Access denied. You are not authorized to access this page. Log in using either an account with the <em>administer software updates</em> permission or the site maintenance account (the account you created during installation). If you cannot log in, you will have to edit <code>settings.php</code> to bypass this access check. To do this:</p>
-<ol>
- <li>With a text editor find the settings.php file on your system. From the main Drupal directory that you installed all the files into, go to <code>sites/your_site_name</code> if such directory exists, or else to <code>sites/default</code> which applies otherwise.</li>
- <li>There is a line inside your settings.php file that says <code>$settings[\'update_free_access\'] = FALSE;</code>. Change it to <code>$settings[\'update_free_access\'] = TRUE;</code>.</li>
- <li>As soon as the update.php script is done, you must change the settings.php file back to its original form with <code>$settings[\'update_free_access\'] = FALSE;</code>.</li>
- <li>To avoid having this problem in the future, remember to log in to your website using either an account with the <em>administer software updates</em> permission or the site maintenance account (the account you created during installation) before you backup your database at the beginning of the update process.</li>
-</ol>';
-}
-
-/**
  * Determines if the current user is allowed to run update.php.
  *
  * @return
@@ -458,7 +438,7 @@ function update_check_requirements($skip_warnings = FALSE) {
   }
 }
 else {
-  $output = update_access_denied_page();
+  $output = maintenance_access_denied_page();
 }
 if (isset($output) && $output) {
   // Explicitly start a session so that the update.php token will be accepted.
