--- path_redirect.module        2009-10-01 22:01:33.000000000 +0000
+++ path_redirect.module        2009-10-05 17:08:49.000000000 +0000
@@ -163,18 +163,19 @@ function _path_redirect_check() {
     $path = urldecode(request_uri());
     $path = drupal_substr($path, drupal_strlen(base_path()));
     // Remove ($language->language .'/') via preg_replace?
-    $path = _path_redirect_split_path($path);
-    $where[] = "(path = '%s' OR path = '%s')";
-    $args[':path'] = $_GET['q'];
-    $args[':path_query'] = $_GET['q'] .'?'. $path['query'];
+    $where[] = "(path = '%s' OR (path like '%%*' AND '%s' REGEXP CONCAT('^',path)))";
+    $args[':path'] = $path;
+    $args[':path_reg'] = $path;
     $sort[] = 'path DESC';
     //$where[] = "(path_query = '%s' OR path_query = '')";
     //$args[':path_query'] = $path['query'];
     //$sort[] = 'path_query DESC';
   }
   else {
-    $where[] = "path = '%s'";
-    $args[':path'] = $_GET['q'];
+    $path = $_GET['q'];
+    $where[] = "(path = '%s' OR (path like '%%*' AND '%s' REGEXP CONCAT('^',path)))";
+    $args[':path'] = $path;
+    $args[':path_reg'] = $path;
     //$where[] = "path_query = ''";
   }

@@ -207,6 +208,20 @@ function _path_redirect_check() {
     else {
       // Perform the redirect.
       unset($_REQUEST['destination']);
+
+      if ($len = strpos($r->path, '*')) {
+        if (strpos($r->redirect, '*')) {
+          $path_split = _path_redirect_split_path($path);
+          $r->redirect = str_replace('*', substr($path_split['path'], $len), $r->redirect);
+          if ($r->query && $path_split['query']) {
+            $r->query = $path_split['query'].'&'.$r->query;
+          }
+          elseif ($path_split['query']) {
+            $r->query = $path_split['query'];
+          }
+        }
+      }
+
       drupal_goto($r->redirect, $r->query, $r->fragment, $r->type);
     }
   }


--- path_redirect.admin.inc	2009-10-06 22:36:07.000000000 +0000
+++ path_redirect.admin.inc	2009-10-06 22:34:26.000000000 +0000
@@ -31,9 +31,9 @@ function path_redirect_admin() {
     $row = array(
       'data' => array(
         // @todo: Revise the following messy, confusing line.
-        l($r->path, preg_replace('/[\?\&].*/', '', $r->path), array('query' => strstr($r->path, '?') ? preg_replace('/.*\?/', '', $r->path) : NULL, 'language' => $r->language ? $languages[$r->language] : NULL)),
+        l($r->path, preg_replace('/[\?\&\*].*/', '', $r->path), array('query' => strstr($r->path, '?') ? preg_replace('/.*\?/', '', $r->path) : NULL, 'language' => $r->language ? $languages[$r->language] : NULL)),
         // @todo: Fix sorting on the redirect field
-        l($redirect, $redirect, array('external' => TRUE)),
+        l(urldecode($redirect), url(preg_replace('/[\*].*/', '', $r->redirect), array('query' => $r->query, 'fragment' => $r->fragment, 'absolute' => TRUE, 'alias' => TRUE)), array('external' => TRUE)),
         $r->type,
         l(t('Edit'), 'admin/build/path-redirect/edit/'. $r->rid, array('query' => drupal_get_destination())),
         l(t('Delete'), 'admin/build/path-redirect/delete/'. $r->rid, array('query' => drupal_get_destination())),
