diff --git a/includes/common.inc b/includes/common.inc
index 3a25c2dc85ab2917aaf148d095dff593c4e09608..99da0b592641847dff340c5c74cae773cfb3adfa 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -170,14 +170,18 @@ function drupal_get_destination() {
     return 'destination='. urlencode($_REQUEST['destination']);
   }
   else {
-    $destination[] = $_GET['q'];
-    $params = array('page', 'sort', 'order');
-    foreach ($params as $param) {
-      if (isset($_GET[$param])) {
-        $destination[] = "$param=". $_GET[$param];
+    $path = $_GET['q'];
+    $params = array();
+    foreach ($_GET as $key => $value) {
+      if ($key == 'q') {
+        continue;
       }
+      $params[] = urlencode($key) .'='. urlencode($value);
     }
-    return 'destination='. urlencode(implode('&', $destination));
+    if (count($params)) {
+      $path .= '?';
+    }
+    return 'destination='. urlencode($path . implode('&', $params));
   }
 }