--- modules/proxy/mod_proxy.h.orig	2007-03-15 21:40:00.000000000 +0100
+++ modules/proxy/mod_proxy.h	2007-03-15 21:41:21.000000000 +0100
@@ -364,6 +364,7 @@
     apr_thread_mutex_t  *mutex;  /* Thread lock for updating lb params */
 #endif
     void            *context;   /* general purpose storage */
+    const char *stickypathid;          /* sticky session identifier as it appears in the path */
 };
 
 struct proxy_balancer_method {
--- modules/proxy/mod_proxy.c.orig	2007-03-15 21:39:49.000000000 +0100
+++ modules/proxy/mod_proxy.c	2007-03-15 22:28:56.000000000 +0100
@@ -281,6 +281,13 @@
          */
         balancer->sticky = apr_pstrdup(p, val);
     }
+    else if (!strcasecmp(key, "stickysessionpathid")) {
+        /* Balancer sticky session name as it appears in the URI.
+         * Set to something like jsessionid or
+         * PHPSESSIONID, etc..,
+         */
+        balancer->stickypathid = apr_pstrdup(p, val);
+    }
     else if (!strcasecmp(key, "nofailover")) {
         /* If set to 'on' the session will break
          * if the worker is in error state or
--- modules/proxy/mod_proxy_balancer.c.orig	2007-03-15 21:40:09.000000000 +0100
+++ modules/proxy/mod_proxy_balancer.c	2007-03-15 22:40:05.000000000 +0100
@@ -245,15 +245,17 @@
 {
     proxy_worker *worker = NULL;
 
-    if (!balancer->sticky)
+    if (!balancer->sticky && !balancer->stickypathid)
         return NULL;
     /* Try to find the sticky route inside url */
-    *route = get_path_param(r->pool, *url, balancer->sticky);
+    *route = get_path_param(r->pool, *url, balancer->stickypathid ? balancer->stickypathid : balancer->sticky);
+    if (!*route && !balancer->sticky)
+        return NULL;
     if (!*route)
         *route = get_cookie_param(r, balancer->sticky);
     ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
                             "proxy: BALANCER: Found value %s for "
-                            "stickysession %s", *route, balancer->sticky);
+                            "stickysession %s (stickysessionpathid %s)", *route, balancer->sticky, balancer->stickypathid);
     /*
      * If we found a value for sticksession, find the first '.' within.
      * Everything after '.' (if present) is our route.
@@ -483,7 +485,7 @@
 
             return HTTP_SERVICE_UNAVAILABLE;
         }
-        if ((*balancer)->sticky && runtime) {
+        if (((*balancer)->sticky || (*balancer)->stickypathid) && runtime) {
             /*
              * This balancer has sticky sessions and the client either has not
              * supplied any routing information or all workers for this route
@@ -514,12 +516,15 @@
     /* Add the session route to request notes if present */
     if (route) {
         apr_table_setn(r->notes, "session-sticky", (*balancer)->sticky);
+        apr_table_setn(r->notes, "session-stickypathid", (*balancer)->stickypathid);
         apr_table_setn(r->notes, "session-route", route);
 
         /* Add session info to env. */
         apr_table_setn(r->subprocess_env,
                        "BALANCER_SESSION_STICKY", (*balancer)->sticky);
         apr_table_setn(r->subprocess_env,
+                       "BALANCER_SESSION_STICKYPATHID", (*balancer)->stickypathid);
+        apr_table_setn(r->subprocess_env,
                        "BALANCER_SESSION_ROUTE", route);
     }
     ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
@@ -650,6 +655,12 @@
             else
                 bsel->sticky = NULL;
         }
+        if ((val = apr_table_get(params, "ssp"))) {
+            if (strlen(val))
+                bsel->stickypathid = apr_pstrdup(conf->pool, val);
+            else
+                bsel->stickypathid = NULL;
+        }
         if ((val = apr_table_get(params, "tm"))) {
             int ival = atoi(val);
             if (ival >= 0)
@@ -753,9 +764,10 @@
                       "\">", NULL);
             ap_rvputs(r, balancer->name, "</a></h3>\n\n", NULL);
             ap_rputs("\n\n<table border=\"0\" style=\"text-align: left;\"><tr>"
-                "<th>StickySession</th><th>Timeout</th><th>FailoverAttempts</th><th>Method</th>"
+                "<th>StickySession</th><th>StickySessionPathId</th><th>Timeout</th><th>FailoverAttempts</th><th>Method</th>"
                 "</tr>\n<tr>", r);
             ap_rvputs(r, "<td>", balancer->sticky, NULL);
+            ap_rvputs(r, "</td><td>", balancer->stickypathid, NULL);
             ap_rprintf(r, "</td><td>%" APR_TIME_T_FMT "</td>",
                 apr_time_sec(balancer->timeout));
             ap_rprintf(r, "<td>%d</td>\n", balancer->max_attempts);
@@ -844,6 +856,9 @@
             ap_rputs("<table><tr><td>StickySession Identifier:</td><td><input name=\"ss\" type=text ", r);
             if (bsel->sticky)
                 ap_rvputs(r, "value=\"", bsel->sticky, "\"", NULL);
+            ap_rputs("></td><tr>\n<tr><td>StickySession Path Identifier:</td><td><input name=\"ssp\" type=text ", r);
+            if (bsel->stickypathid)
+                ap_rvputs(r, "value=\"", bsel->stickypathid, "\"", NULL);
             ap_rputs("></td><tr>\n<tr><td>Timeout:</td><td><input name=\"tm\" type=text ", r);
             ap_rprintf(r, "value=\"%" APR_TIME_T_FMT "\"></td></tr>\n",
                        apr_time_sec(bsel->timeout));
