--- path_redirect.module        2007-10-06 20:12:11.539744250 -0500
+++ path_redirect.module.new    2007-10-06 20:12:38.053401250 -0500
@@ -25,8 +25,24 @@ function path_redirect_help($section) {
 function path_redirect_init() {
   // check through the redirects
   // see if this page is one of those
-  $path = db_escape_string($_GET['q']);
-  $r = db_fetch_object(db_query("SELECT redirect, query, fragment, type FROM {path_redirect} WHERE path = '%s'", $path));
+
+  // Assumption:
+  //   The order of the variables matches that given
+  
+  // OK, clean up the request so that it's consistent - there might be a cleaner way of doing this using regular expressions
+  $presentedPath = urldecode(trim($_SERVER['REQUEST_URI'], '/'));
+  if (substr($presentedPath, 0, 3) == "?q=") {
+    $presentedPath = substr($presentedPath, 3);
+    $ampPos = strpos($presentedPath, "&");
+    if ($ampPos !== FALSE) {
+      $presentedPath = substr($presentedPath, 0, $ampPos) . "?" . substr($presentedPath, $ampPos + 1);
+    }
+  }
+  $testURL = drupal_get_normal_path($presentedPath);
+  
+  // Use the base case
+  $r = db_fetch_object(db_query('SELECT redirect, query, fragment, type FROM {path_redirect} WHERE path = "%s"', $testURL));
+  
   if ($r) {
     drupal_goto($r->redirect, ($r->query ? $r->query: NULL), ($r->fragment ? $r->fragment : NULL), $r->type);
   }
@@ -248,9 +264,6 @@ function path_redirect_edit_validate($fo
   elseif (strstr($form_values['path'], '#')) {
     form_set_error('path', t('You cannot redirect from a fragment anchor.'));
   }
-  elseif (strstr($form_values['path'], '?')) {
-    form_set_error('path', t('You cannot currently include a query in your redirect <strong>from</strong> path.'));
-  }
   elseif (!valid_url($form_values['path'])) {
     form_set_error('path', t('The redirect <strong>from</strong> path does not appear valid. This must be a local Drupal path.'));
   }
