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