]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
rewrite: warn that <If>/<Location>/<Directory> silently switch to per-directory context
authorRich Bowen <rbowen@apache.org>
Wed, 20 May 2026 20:52:26 +0000 (20:52 +0000)
committerRich Bowen <rbowen@apache.org>
Wed, 20 May 2026 20:52:26 +0000 (20:52 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1934451 13f79535-47bb-0310-9956-ffa450edef68

docs/manual/rewrite/htaccess.xml
docs/manual/rewrite/intro.xml

index 143ed3fae71ac2a316bc2ed5f4c642e37bbc2517..5db5037db3b5c0b47d23748723e8e532958963e1 100644 (file)
@@ -317,6 +317,23 @@ unsupported and should never be necessary. Relative
 substitutions, in particular, are likely to break in
 these contexts.</p>
 
+<note type="warning"><title>These containers silently change rewrite
+behavior</title>
+<p>Placing a <directive module="mod_rewrite">RewriteRule</directive>
+inside a <directive module="core" type="section">Directory</directive>,
+<directive module="core" type="section">If</directive>, or
+<directive module="core" type="section">Location</directive> block
+&mdash; even inside a
+<directive module="core" type="section">VirtualHost</directive> in the
+main server config &mdash; silently switches to
+<glossary ref="perdirectory">per-directory context</glossary> behavior.
+This means the leading slash is stripped from the URL before pattern
+matching, substitutions trigger an internal redirect (with loop risk),
+and the <a href="../rewrite/flags.html#flag_l">[L]</a> flag no longer
+truly stops processing &mdash; use
+<a href="../rewrite/flags.html#flag_end">[END]</a> instead.</p>
+</note>
+
 </section>
 
 <section id="inheritance"><title>Rule inheritance with RewriteOptions</title>
index cb25d1c3850097b8c5518ec2218f70c41b7261d5..cd6f40555976ea575956a647bfad5903173f6daa 100644 (file)
@@ -409,7 +409,11 @@ href="rewritemap.html">RewriteMap supplementary documentation</a>.</p>
 but the rules behave differently there — in particular, the directory
 prefix is stripped from the URL before matching. See the
 <a href="htaccess.html#path-stripping">Per-directory Rewrites</a>
-document for full details.</p>
+document for full details. Note that
+<directive module="core" type="section">If</directive> and
+<directive module="core" type="section">Location</directive> blocks
+also trigger per-directory behavior &mdash; see
+<a href="htaccess.html#context-restrictions">Which contexts support rewrite rules?</a>.</p>
 
 </section>