fb3f8d
diff --git a/server/request.c b/server/request.c
fb3f8d
index d5c558a..18625af 100644
fb3f8d
--- a/server/request.c
fb3f8d
+++ b/server/request.c
fb3f8d
@@ -1419,7 +1419,20 @@ AP_DECLARE(int) ap_location_walk(request_rec *r)
fb3f8d
 
fb3f8d
     cache = prep_walk_cache(AP_NOTE_LOCATION_WALK, r);
fb3f8d
     cached = (cache->cached != NULL);
fb3f8d
-    entry_uri = r->uri;
fb3f8d
+
fb3f8d
+   /*
fb3f8d
+    * When merge_slashes is set to AP_CORE_CONFIG_OFF the slashes in r->uri
fb3f8d
+    * have not been merged. But for Location walks we always go with merged
fb3f8d
+    * slashes no matter what merge_slashes is set to.
fb3f8d
+    */
fb3f8d
+    if (sconf->merge_slashes != AP_CORE_CONFIG_OFF) {
fb3f8d
+        entry_uri = r->uri;
fb3f8d
+    }
fb3f8d
+    else {
fb3f8d
+        char *uri = apr_pstrdup(r->pool, r->uri);
fb3f8d
+        ap_no2slash(uri);
fb3f8d
+        entry_uri = uri;
fb3f8d
+    }
fb3f8d
 
fb3f8d
     /* If we have an cache->cached location that matches r->uri,
fb3f8d
      * and the vhost's list of locations hasn't changed, we can skip
fb3f8d
@@ -1486,7 +1499,7 @@ AP_DECLARE(int) ap_location_walk(request_rec *r)
fb3f8d
                     pmatch = apr_palloc(rxpool, nmatch*sizeof(ap_regmatch_t));
fb3f8d
                 }
fb3f8d
 
fb3f8d
-                if (ap_regexec(entry_core->r, entry_uri, nmatch, pmatch, 0)) {
fb3f8d
+                if (ap_regexec(entry_core->r, r->uri, nmatch, pmatch, 0)) {
fb3f8d
                     continue;
fb3f8d
                 }
fb3f8d
 
fb3f8d
@@ -1496,7 +1509,7 @@ AP_DECLARE(int) ap_location_walk(request_rec *r)
fb3f8d
                         apr_table_setn(r->subprocess_env,
fb3f8d
                                        ((const char **)entry_core->refs->elts)[i],
fb3f8d
                                        apr_pstrndup(r->pool,
fb3f8d
-                                       entry_uri + pmatch[i].rm_so,
fb3f8d
+                                       r->uri + pmatch[i].rm_so,
fb3f8d
                                        pmatch[i].rm_eo - pmatch[i].rm_so));
fb3f8d
                     }
fb3f8d
                 }