From: Rich Bowen
Date: Thu, 21 May 2026 16:24:04 +0000 (+0000)
Subject: Clarify the role of ! in regular expressions and backreferences
X-Git-Tag: 2.4.68-rc1-candidate~102
X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=af404cfa1a8744b79a9eeda4c590ee7aa3201b80;p=thirdparty%2Fapache%2Fhttpd.git
Clarify the role of ! in regular expressions and backreferences
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1934481 13f79535-47bb-0310-9956-ffa450edef68
---
diff --git a/docs/manual/mod/mod_rewrite.xml b/docs/manual/mod/mod_rewrite.xml
index 56ff647891..ac83448f6f 100644
--- a/docs/manual/mod/mod_rewrite.xml
+++ b/docs/manual/mod/mod_rewrite.xml
@@ -443,7 +443,7 @@ RewriteRule "^/ex/(.*)" "${examplemap:$1}"
Defines a condition under which rewriting will take place
RewriteCond
- TestString CondPattern [flags]
+ TestString [!]CondPattern [flags]
server configvirtual host
directory.htaccess
FileInfo
@@ -456,6 +456,10 @@ RewriteRule "^/ex/(.*)" "${examplemap:$1}"
the current state of the URI matches its pattern, and if these conditions are met.
+ If the CondPattern is prefixed with a ! the
+ condition is determined to be true only if the the
+ CondPattern does not match.
+
TestString is a string which can contain the
following expanded constructs in addition to plain text:
@@ -468,6 +472,10 @@ RewriteRule "^/ex/(.*)" "${examplemap:$1}"
RewriteRule which is subject to the current
set of RewriteCond conditions. $0 provides
access to the whole string matched by that pattern.
+
+ Backreferences are only defined if the pattern
+ matches. Thus, if the pattern is prefixed with
+ !<.code>, no backreferences are ever defined.
RewriteCond backreferences: These are
@@ -477,6 +485,10 @@ RewriteRule "^/ex/(.*)" "${examplemap:$1}"
RewriteCond in the current set
of conditions. %0 provides access to the whole string matched by
that pattern.
+
+ Backreferences are only defined if the pattern
+ matches. Thus, if the pattern is prefixed with
+ !<.code>, no backreferences are ever defined.
RewriteMap expansions: These are
@@ -1072,7 +1084,7 @@ RewriteRule "^/$" "/homepage.std.html" [L]
RewriteRule
Defines rules for the rewriting engine
RewriteRule
- Pattern Substitution [flags]
+ [!]Pattern Substitution [flags]
server configvirtual host
directory.htaccess
FileInfo
@@ -1089,6 +1101,10 @@ RewriteRule "^/$" "/homepage.std.html" [L]
expression. What this pattern is compared against varies depending
on where the RewriteRule directive is defined.
+ If the pattern is prefixed with a ! the
+ substitution will be performed only if the the
+ pattern does not match.
+
What is matched?