diff --git a/google_cse_adv.module b/google_cse_adv.module
index 9dbd5b7..aefb8fd 100644
--- a/google_cse_adv.module
+++ b/google_cse_adv.module
@@ -148,6 +148,17 @@ function google_cse_adv_form_search_block_form_alter(&$form, $form_state) {
  * @see apachesolr_search_search_box_form_submit()
  */
 function google_cse_adv_search_box_form_submit($form, &$form_state) {
+  // The search form relies on control of the redirect destination for its
+  // functionality, so we override any static destination set in the request,
+  // for example by drupal_access_denied() or drupal_not_found()
+  // (see http://drupal.org/node/292565).
+  if (isset($_REQUEST['destination'])) {
+    unset($_REQUEST['destination']);
+  }
+  if (isset($_REQUEST['edit']['destination'])) {
+    unset($_REQUEST['edit']['destination']);
+  }
+
   $form_id = $form['form_id']['#value'];
   $keys = $form_state['values'][$form_id];
   // Handle Apache webserver clean URL quirks.
