Index: modules/proxy/mod_proxy.c
===================================================================
--- modules/proxy/mod_proxy.c	(revision 1579155)
+++ modules/proxy/mod_proxy.c	(working copy)
@@ -1631,8 +1631,29 @@
         new->balancer = balancer;
     }
     else {
-        proxy_worker *worker = ap_proxy_get_worker(cmd->temp_pool, NULL, conf, de_socketfy(cmd->pool, r));
+        proxy_worker *worker;
         int reuse = 0;
+        /* When the scheme or the hostname contains '$', skip.
+         * When the path contains '$N', replace '$N' with wildcard. */
+        if (use_regex) {
+            char *r2 = apr_pstrdup(cmd->temp_pool, r);
+            char *x, *y;
+            y = ap_strstr(r2, "://");
+            if (y != NULL) {
+                for (x = y; *y; ++x, ++y) {
+                    if (*y != '$') {
+                        *x = *y;
+                    }
+                    else if (apr_isdigit(*(y + 1))) {
+                        *x = '*';
+                        y += 1;
+                    }
+                }
+                *x = '\0';
+            }
+            r = r2;
+        }
+        worker = ap_proxy_get_worker(cmd->temp_pool, NULL, conf, r);
         if (!worker) {
             const char *err = ap_proxy_define_worker(cmd->pool, &worker, NULL, conf, r, 0);
             if (err)
Index: modules/proxy/proxy_util.c
===================================================================
--- modules/proxy/proxy_util.c	(revision 1579155)
+++ modules/proxy/proxy_util.c	(working copy)
@@ -1568,7 +1568,8 @@
             if ( ((worker_name_length = strlen(worker->s->name)) <= url_length)
                 && (worker_name_length >= min_match)
                 && (worker_name_length > max_match)
-                && (strncmp(url_copy, worker->s->name, worker_name_length) == 0) ) {
+                && (ap_strcmp_match(url_copy, worker->s->name) == 0
+                || (strncmp(url_copy, worker->s->name, worker_name_length) == 0)) ) {
                 max_worker = worker;
                 max_match = worker_name_length;
             }
@@ -1580,7 +1581,8 @@
             if ( ((worker_name_length = strlen(worker->s->name)) <= url_length)
                 && (worker_name_length >= min_match)
                 && (worker_name_length > max_match)
-                && (strncmp(url_copy, worker->s->name, worker_name_length) == 0) ) {
+                && (ap_strcmp_match(url_copy, worker->s->name) == 0
+                || (strncmp(url_copy, worker->s->name, worker_name_length) == 0)) ) {
                 max_worker = worker;
                 max_match = worker_name_length;
             }
