a4f3a1
diff --git a/include/ap_regex.h b/include/ap_regex.h
a4f3a1
index 349ae83..952e77a 100644
a4f3a1
--- a/include/ap_regex.h
a4f3a1
+++ b/include/ap_regex.h
a4f3a1
@@ -79,6 +79,12 @@ extern "C" {
a4f3a1
 
a4f3a1
 #define AP_REG_DOLLAR_ENDONLY 0x200 /**< '$' matches at end of subject string only */
a4f3a1
 
a4f3a1
+#define AP_REG_NO_DEFAULT 0x400 /**< Don't implicitely add AP_REG_DEFAULT options */
a4f3a1
+
a4f3a1
+#define AP_REG_MATCH "MATCH_" /**< suggested prefix for ap_regname */
a4f3a1
+
a4f3a1
+#define AP_REG_DEFAULT (AP_REG_DOTALL|AP_REG_DOLLAR_ENDONLY)
a4f3a1
+
a4f3a1
 /* Error values: */
a4f3a1
 enum {
a4f3a1
   AP_REG_ASSERT = 1,  /** internal error ? */
a4f3a1
diff --git a/modules/filters/mod_substitute.c b/modules/filters/mod_substitute.c
a4f3a1
index 15cd8ee..69af111 100644
a4f3a1
--- a/modules/filters/mod_substitute.c
a4f3a1
+++ b/modules/filters/mod_substitute.c
a4f3a1
@@ -599,8 +599,10 @@ static const char *set_pattern(cmd_parms *cmd, void *cfg, const char *line)
a4f3a1
 
a4f3a1
     /* first see if we can compile the regex */
a4f3a1
     if (!is_pattern) {
a4f3a1
-        r = ap_pregcomp(cmd->pool, from, AP_REG_EXTENDED |
a4f3a1
-                        (ignore_case ? AP_REG_ICASE : 0));
a4f3a1
+        int flags = AP_REG_NO_DEFAULT
a4f3a1
+                    | (ap_regcomp_get_default_cflags() & AP_REG_DOLLAR_ENDONLY)
a4f3a1
+                    | (ignore_case ? AP_REG_ICASE : 0);
a4f3a1
+        r = ap_pregcomp(cmd->pool, from, flags);
a4f3a1
         if (!r)
a4f3a1
             return "Substitute could not compile regex";
a4f3a1
     }
a4f3a1
diff --git a/server/core.c b/server/core.c
a4f3a1
index d4af287..6ae0f5f 100644
a4f3a1
--- a/server/core.c
a4f3a1
+++ b/server/core.c
a4f3a1
@@ -4625,7 +4625,7 @@ static int core_pre_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptem
a4f3a1
     apr_pool_cleanup_register(pconf, NULL, reset_config_defines,
a4f3a1
                               apr_pool_cleanup_null);
a4f3a1
 
a4f3a1
-    ap_regcomp_set_default_cflags(AP_REG_DOLLAR_ENDONLY);
a4f3a1
+    ap_regcomp_set_default_cflags(AP_REG_DEFAULT);
a4f3a1
 
a4f3a1
     mpm_common_pre_config(pconf);
a4f3a1
 
a4f3a1
diff --git a/server/util_pcre.c b/server/util_pcre.c
a4f3a1
index d7df400..f778c75 100644
a4f3a1
--- a/server/util_pcre.c
a4f3a1
+++ b/server/util_pcre.c
a4f3a1
@@ -110,7 +110,7 @@ AP_DECLARE(void) ap_regfree(ap_regex_t *preg)
a4f3a1
  *            Compile a regular expression       *
a4f3a1
  *************************************************/
a4f3a1
 
a4f3a1
-static int default_cflags = AP_REG_DOLLAR_ENDONLY;
a4f3a1
+static int default_cflags = AP_REG_DEFAULT;
a4f3a1
 
a4f3a1
 AP_DECLARE(int) ap_regcomp_get_default_cflags(void)
a4f3a1
 {
a4f3a1
@@ -158,7 +158,8 @@ AP_DECLARE(int) ap_regcomp(ap_regex_t * preg, const char *pattern, int cflags)
a4f3a1
     int errcode = 0;
a4f3a1
     int options = 0;
a4f3a1
 
a4f3a1
-    cflags |= default_cflags;
a4f3a1
+    if ((cflags & AP_REG_NO_DEFAULT) == 0)
a4f3a1
+        cflags |= default_cflags;
a4f3a1
     if ((cflags & AP_REG_ICASE) != 0)
a4f3a1
         options |= PCRE_CASELESS;
a4f3a1
     if ((cflags & AP_REG_NEWLINE) != 0)
a4f3a1
diff --git a/server/util_regex.c b/server/util_regex.c
a4f3a1
index 73eccec..5038b99 100644
a4f3a1
--- a/server/util_regex.c
a4f3a1
+++ b/server/util_regex.c
a4f3a1
@@ -93,6 +93,7 @@ AP_DECLARE(ap_rxplus_t*) ap_rxplus_compile(apr_pool_t *pool,
a4f3a1
     }
a4f3a1
 
a4f3a1
     /* anything after the current delimiter is flags */
a4f3a1
+    ret->flags = ap_regcomp_get_default_cflags() & AP_REG_DOLLAR_ENDONLY;
a4f3a1
     while (*++endp) {
a4f3a1
         switch (*endp) {
a4f3a1
         case 'i': ret->flags |= AP_REG_ICASE; break;
a4f3a1
@@ -105,7 +106,7 @@ AP_DECLARE(ap_rxplus_t*) ap_rxplus_compile(apr_pool_t *pool,
a4f3a1
         default: break; /* we should probably be stricter here */
a4f3a1
         }
a4f3a1
     }
a4f3a1
-    if (ap_regcomp(&ret->rx, rxstr, ret->flags) == 0) {
a4f3a1
+    if (ap_regcomp(&ret->rx, rxstr, AP_REG_NO_DEFAULT | ret->flags) == 0) {
a4f3a1
         apr_pool_cleanup_register(pool, &ret->rx, rxplus_cleanup,
a4f3a1
                                   apr_pool_cleanup_null);
a4f3a1
     }