From: Rich Bowen Date: Fri, 15 May 2026 15:23:37 +0000 (+0000) Subject: Consolidates advice about crafting regular expressions in one place, X-Git-Tag: 2.4.68-rc1-candidate~126 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=deab10ab74425fba770c8a41b8152ddb61a267dc;p=thirdparty%2Fapache%2Fhttpd.git Consolidates advice about crafting regular expressions in one place, rather than having it duplicated in two docs git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1934223 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/docs/manual/mod/mod_rewrite.xml b/docs/manual/mod/mod_rewrite.xml index cc0183daed..6acbc14caa 100644 --- a/docs/manual/mod/mod_rewrite.xml +++ b/docs/manual/mod/mod_rewrite.xml @@ -1196,21 +1196,11 @@ sections and consider both set of statements, rather than only the last one.mod_rewrite Introduction.

-

In mod_rewrite, the NOT character - ('!') is also available as a possible pattern - prefix. This enables you to negate a pattern; to say, for instance: - ``if the current URL does NOT match this - pattern''. This can be used for exceptional cases, where - it is easier to match the negative pattern, or as a last - default rule.

- -Note -When using the NOT character to negate a pattern, you cannot include -grouped wildcard parts in that pattern. This is because, when the -pattern does NOT match (ie, the negation matches), there are no -contents for the groups. Thus, if negated patterns are used, you -cannot use $N in the substitution string! - +

For information on regular + expressions, including the use of the + ! prefix to negate a pattern, see the + Regular Expressions + section of the mod_rewrite introduction.

The Substitution of a rewrite rule is the string that replaces the original URL-path that diff --git a/docs/manual/rewrite/intro.xml b/docs/manual/rewrite/intro.xml index ebeb393263..95b98c9623 100644 --- a/docs/manual/rewrite/intro.xml +++ b/docs/manual/rewrite/intro.xml @@ -163,11 +163,23 @@ well as write your own.

not c/t -

In mod_rewrite the ! character can be +

The ! (Not) character can be used before a regular expression to negate it. This is, a string will be considered to have matched only if it does not match the rest of the expression.

+

When using ! to negate a pattern, note that +backreferences (e.g. +$1, $2) are not available, since the +pattern does not match.

+ +

For example, the following will redirect any request that does +not start with /admin

+ + +RewriteRule "!^/admin" "/xyz.html" [R,L] + +
Regex Back-Reference Availability