Index: include/http_core.h
===================================================================
--- include/http_core.h	(revision 1633083)
+++ include/http_core.h	(working copy)
@@ -619,6 +619,7 @@
 
     unsigned int allow_encoded_slashes_set : 1;
     unsigned int decode_encoded_slashes_set : 1;
+    unsigned int d_is_directory : 1;
 
     /** Named back references */
     apr_array_header_t *refs;
Index: server/core.c
===================================================================
--- server/core.c	(revision 1633083)
+++ server/core.c	(working copy)
@@ -2224,6 +2224,7 @@
     conf->r = r;
     conf->d = cmd->path;
     conf->d_is_fnmatch = (apr_fnmatch_test(conf->d) != 0);
+    conf->d_is_directory = 1;
 
     if (r) {
         conf->refs = apr_array_make(cmd->pool, 8, sizeof(char *));
Index: server/request.c
===================================================================
--- server/request.c	(revision 1633083)
+++ server/request.c	(working copy)
@@ -1216,6 +1216,13 @@
                 pmatch = apr_palloc(rxpool, nmatch*sizeof(ap_regmatch_t));
             }
 
+            /* core_dir_config is Directory*, but the requested file is
+             * not a directory, so although the regexp could match,
+             * we skip it. */
+            if (entry_core->d_is_directory && r->finfo.filetype != APR_DIR) {
+                continue;
+            }
+
             if (ap_regexec(entry_core->r, r->filename, nmatch, pmatch, 0)) {
                 continue;
             }
