a4f3a1
diff --git a/include/ap_regex.h b/include/ap_regex.h
a4f3a1
index 5122154..349ae83 100644
a4f3a1
--- a/include/ap_regex.h
a4f3a1
+++ b/include/ap_regex.h
a4f3a1
@@ -77,6 +77,8 @@ extern "C" {
a4f3a1
 #define AP_REG_NOMEM 0x20    /* nomem in our code */
a4f3a1
 #define AP_REG_DOTALL 0x40   /* perl's /s flag */
a4f3a1
 
a4f3a1
+#define AP_REG_DOLLAR_ENDONLY 0x200 /**< '$' matches at end of subject string only */
a4f3a1
+
a4f3a1
 /* Error values: */
a4f3a1
 enum {
a4f3a1
   AP_REG_ASSERT = 1,  /** internal error ? */
a4f3a1
@@ -100,6 +102,26 @@ typedef struct {
a4f3a1
 
a4f3a1
 /* The functions */
a4f3a1
 
a4f3a1
+/**
a4f3a1
+ * Get default compile flags
a4f3a1
+ * @return Bitwise OR of AP_REG_* flags
a4f3a1
+ */
a4f3a1
+AP_DECLARE(int) ap_regcomp_get_default_cflags(void);
a4f3a1
+
a4f3a1
+/**
a4f3a1
+ * Set default compile flags
a4f3a1
+ * @param cflags Bitwise OR of AP_REG_* flags
a4f3a1
+ */
a4f3a1
+AP_DECLARE(void) ap_regcomp_set_default_cflags(int cflags);
a4f3a1
+
a4f3a1
+/**
a4f3a1
+ * Get the AP_REG_* corresponding to the string.
a4f3a1
+ * @param name The name (i.e. AP_REG_<name>)
a4f3a1
+ * @return The AP_REG_*, or zero if the string is unknown
a4f3a1
+ *
a4f3a1
+ */
a4f3a1
+AP_DECLARE(int) ap_regcomp_default_cflag_by_name(const char *name);
a4f3a1
+
a4f3a1
 /**
a4f3a1
  * Compile a regular expression.
a4f3a1
  * @param preg Returned compiled regex
a4f3a1
diff --git a/server/core.c b/server/core.c
a4f3a1
index b3240a0..e073ddf 100644
a4f3a1
--- a/server/core.c
a4f3a1
+++ b/server/core.c
a4f3a1
@@ -48,6 +48,7 @@
a4f3a1
 #include "mod_core.h"
a4f3a1
 #include "mod_proxy.h"
a4f3a1
 #include "ap_listen.h"
a4f3a1
+#include "ap_regex.h"
a4f3a1
 
a4f3a1
 #include "mod_so.h" /* for ap_find_loaded_module_symbol */
a4f3a1
 
a4f3a1
@@ -2646,6 +2647,58 @@ static const char *virtualhost_section(cmd_parms *cmd, void *dummy,
a4f3a1
     return errmsg;
a4f3a1
 }
a4f3a1
 
a4f3a1
+static const char *set_regex_default_options(cmd_parms *cmd,
a4f3a1
+                                             void *dummy,
a4f3a1
+                                             const char *arg)
a4f3a1
+{
a4f3a1
+    const command_rec *thiscmd = cmd->cmd;
a4f3a1
+    int cflags, cflag;
a4f3a1
+
a4f3a1
+    const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
a4f3a1
+    if (err != NULL) {
a4f3a1
+        return err;
a4f3a1
+    }
a4f3a1
+
a4f3a1
+    cflags = ap_regcomp_get_default_cflags();
a4f3a1
+    while (*arg) {
a4f3a1
+        const char *name = ap_getword_conf(cmd->pool, &arg;;
a4f3a1
+        int how = 0;
a4f3a1
+
a4f3a1
+        if (strcasecmp(name, "none") == 0) {
a4f3a1
+            cflags = 0;
a4f3a1
+            continue;
a4f3a1
+        }
a4f3a1
+
a4f3a1
+        if (*name == '+') {
a4f3a1
+            name++;
a4f3a1
+            how = +1;
a4f3a1
+        }
a4f3a1
+        else if (*name == '-') {
a4f3a1
+            name++;
a4f3a1
+            how = -1;
a4f3a1
+        }
a4f3a1
+
a4f3a1
+        cflag = ap_regcomp_default_cflag_by_name(name);
a4f3a1
+        if (!cflag) {
a4f3a1
+            return apr_psprintf(cmd->pool, "%s: option '%s' unknown",
a4f3a1
+                                thiscmd->name, name);
a4f3a1
+        }
a4f3a1
+
a4f3a1
+        if (how > 0) {
a4f3a1
+            cflags |= cflag;
a4f3a1
+        }
a4f3a1
+        else if (how < 0) {
a4f3a1
+            cflags &= ~cflag;
a4f3a1
+        }
a4f3a1
+        else {
a4f3a1
+            cflags = cflag;
a4f3a1
+        }
a4f3a1
+    }
a4f3a1
+    ap_regcomp_set_default_cflags(cflags);
a4f3a1
+
a4f3a1
+    return NULL;
a4f3a1
+}
a4f3a1
+
a4f3a1
 static const char *set_server_alias(cmd_parms *cmd, void *dummy,
a4f3a1
                                     const char *arg)
a4f3a1
 {
a4f3a1
@@ -4164,6 +4217,9 @@ AP_INIT_TAKE12("RLimitNPROC", no_set_limit, NULL,
a4f3a1
    OR_ALL, "soft/hard limits for max number of processes per uid"),
a4f3a1
 #endif
a4f3a1
 
a4f3a1
+AP_INIT_RAW_ARGS("RegexDefaultOptions", set_regex_default_options, NULL, RSRC_CONF,
a4f3a1
+                 "default options for regexes (prefixed by '+' to add, '-' to del)"),
a4f3a1
+
a4f3a1
 /* internal recursion stopper */
a4f3a1
 AP_INIT_TAKE12("LimitInternalRecursion", set_recursion_limit, NULL, RSRC_CONF,
a4f3a1
               "maximum recursion depth of internal redirects and subrequests"),
a4f3a1
@@ -4569,6 +4625,8 @@ 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
+
a4f3a1
     mpm_common_pre_config(pconf);
a4f3a1
 
a4f3a1
     return OK;
a4f3a1
diff --git a/server/util_pcre.c b/server/util_pcre.c
a4f3a1
index 1e83cad..d7df400 100644
a4f3a1
--- a/server/util_pcre.c
a4f3a1
+++ b/server/util_pcre.c
a4f3a1
@@ -110,6 +110,38 @@ 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
+
a4f3a1
+AP_DECLARE(int) ap_regcomp_get_default_cflags(void)
a4f3a1
+{
a4f3a1
+    return default_cflags;
a4f3a1
+}
a4f3a1
+
a4f3a1
+AP_DECLARE(void) ap_regcomp_set_default_cflags(int cflags)
a4f3a1
+{
a4f3a1
+    default_cflags = cflags;
a4f3a1
+}
a4f3a1
+
a4f3a1
+AP_DECLARE(int) ap_regcomp_default_cflag_by_name(const char *name)
a4f3a1
+{
a4f3a1
+    int cflag = 0;
a4f3a1
+
a4f3a1
+    if (strcasecmp(name, "ICASE") == 0) {
a4f3a1
+        cflag = AP_REG_ICASE;
a4f3a1
+    }
a4f3a1
+    else if (strcasecmp(name, "DOTALL") == 0) {
a4f3a1
+        cflag = AP_REG_DOTALL;
a4f3a1
+    }
a4f3a1
+    else if (strcasecmp(name, "DOLLAR_ENDONLY") == 0) {
a4f3a1
+        cflag = AP_REG_DOLLAR_ENDONLY;
a4f3a1
+    }
a4f3a1
+    else if (strcasecmp(name, "EXTENDED") == 0) {
a4f3a1
+        cflag = AP_REG_EXTENDED;
a4f3a1
+    }
a4f3a1
+
a4f3a1
+    return cflag;
a4f3a1
+}
a4f3a1
+
a4f3a1
 /*
a4f3a1
  * Arguments:
a4f3a1
  *  preg        points to a structure for recording the compiled expression
a4f3a1
@@ -126,12 +158,16 @@ 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_ICASE) != 0)
a4f3a1
         options |= PCRE_CASELESS;
a4f3a1
     if ((cflags & AP_REG_NEWLINE) != 0)
a4f3a1
         options |= PCRE_MULTILINE;
a4f3a1
     if ((cflags & AP_REG_DOTALL) != 0)
a4f3a1
         options |= PCRE_DOTALL;
a4f3a1
+    if ((cflags & AP_REG_DOLLAR_ENDONLY) != 0)
a4f3a1
+        options |= PCRE_DOLLAR_ENDONLY;
a4f3a1
+
a4f3a1
 
a4f3a1
     preg->re_pcre =
a4f3a1
         pcre_compile2(pattern, options, &errcode, &errorptr, &erroffset, NULL);