From: Rich Bowen
Date: Sun, 17 May 2026 22:30:48 +0000 (+0000)
Subject: rewrite docs: Add warning box for leading-slash patterns in .htaccess, add section...
X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=f7d50a0c848456f47a5fcfcbfdab09e25104d00b;p=thirdparty%2Fapache%2Fhttpd.git
rewrite docs: Add warning box for leading-slash patterns in .htaccess, add section on 301 browser caching
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1934325 13f79535-47bb-0310-9956-ffa450edef68
---
diff --git a/docs/manual/rewrite/htaccess.xml b/docs/manual/rewrite/htaccess.xml
index 02ddd88340..143ed3fae7 100644
--- a/docs/manual/rewrite/htaccess.xml
+++ b/docs/manual/rewrite/htaccess.xml
@@ -132,12 +132,16 @@ mechanism is also why rules can loop — see
below.
+Do not start .htaccess patterns with /
Because the directory prefix (including the trailing
slash) is stripped before matching, patterns in
per-directory context
will never match a leading slash. A pattern
beginning with ^/ will never match in this
-context.
+context. A rule like RewriteRule "^/foo" ... will
+silently fail to match anything when placed in a
+.htaccess file.
+
If you need to match against the full original
URL-path (including the directory prefix), use
@@ -384,4 +388,28 @@ performance.
+Browser caching of 301 redirects
+
+When you issue a 301 Moved Permanently redirect
+(via [R=301] or Redirect permanent), the browser is allowed to cache
+that response indefinitely. This means that even after you fix an
+incorrect redirect rule in your configuration, returning visitors
+may continue to be sent to the old (wrong) destination without
+ever contacting your server again.
+
+While debugging redirect rules, use [R=302]
+(temporary redirect) instead of [R=301]. Switch to 301
+only after you have confirmed the rule is correct. If you have
+already issued an incorrect 301, affected users will need to clear
+their browser cache (or use a private/incognito window) to see
+the corrected behavior.
+
+Search engines also cache 301 redirects. An incorrect 301
+may take days or weeks to be re-crawled, even after the
+configuration is fixed. This is another reason to test with 302
+first.
+
+
+