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