]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Consolidates advice about crafting regular expressions in one place,
authorRich Bowen <rbowen@apache.org>
Fri, 15 May 2026 15:23:37 +0000 (15:23 +0000)
committerRich Bowen <rbowen@apache.org>
Fri, 15 May 2026 15:23:37 +0000 (15:23 +0000)
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

docs/manual/mod/mod_rewrite.xml
docs/manual/rewrite/intro.xml

index cc0183daed05dafd7314b8ddab3b5acc8df982fc..6acbc14caa0e645179b7fafd0c91d6d0617e2039 100644 (file)
@@ -1196,21 +1196,11 @@ sections and consider both set of statements, rather than only the last one.</li
       the <a href="../rewrite/intro.html#regex">mod_rewrite
       Introduction</a>.</p>
 
-      <p>In <module>mod_rewrite</module>, the NOT character
-      ('<code>!</code>') is also available as a possible pattern
-      prefix. This enables you to negate a pattern; to say, for instance:
-      ``<em>if the current URL does <strong>NOT</strong> match this
-      pattern</em>''. This can be used for exceptional cases, where
-      it is easier to match the negative pattern, or as a last
-      default rule.</p>
-
-<note><title>Note</title>
-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 <code>$N</code> in the substitution string!
-</note>
+      <p>For information on <glossary ref="regex">regular
+      expressions</glossary>, including the use of the
+      <code>!</code> prefix to negate a pattern, see the
+      <a href="../rewrite/intro.html#regex">Regular Expressions</a>
+      section of the mod_rewrite introduction.</p>
 
       <p>The <a id="rhs" name="rhs"><em>Substitution</em></a> of a
       rewrite rule is the string that replaces the original URL-path that
index ebeb3932631e16ed5a101b3e0f508b99f0555645..95b98c96231dae51d4b7234d2f6809c5d60c71e4 100644 (file)
@@ -163,11 +163,23 @@ well as write your own.</p>
       not <code>c/t</code></td></tr>
 </table>
 
-<p>In <module>mod_rewrite</module> the <code>!</code> character can be
+<p>The <code>!</code> (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.</p>
 
+<p>When using <code>!</code> to negate a pattern, note that
+<a href="#InternalBackRefs">backreferences</a> (e.g.
+<code>$1</code>, <code>$2</code>) are not available, since the
+pattern does not match.</p>
+
+<p>For example, the following will redirect any request that does
+<em>not</em> start with <code>/admin</code></p>
+
+<highlight language="config">
+RewriteRule "!^/admin" "/xyz.html" [R,L]
+</highlight>
+
 </section>
 
 <section id="InternalBackRefs"><title>Regex Back-Reference Availability</title>