From: Rich Bowen
Date: Sat, 2 May 2026 19:31:33 +0000 (+0000)
Subject: rewrite guide: add FallbackResource and If-expression sections to avoid.xml (BZ 58892...
X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ee39dbe0995b51f12055584d27f5468ca1ec1641;p=thirdparty%2Fapache%2Fhttpd.git
rewrite guide: add FallbackResource and If-expression sections to avoid.xml (BZ 58892, step 10)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1933711 13f79535-47bb-0310-9956-ffa450edef68
---
diff --git a/docs/manual/rewrite/avoid.xml b/docs/manual/rewrite/avoid.xml
index ac9084b0d6..230f143d89 100644
--- a/docs/manual/rewrite/avoid.xml
+++ b/docs/manual/rewrite/avoid.xml
@@ -240,6 +240,82 @@ and in certain other directives.
+Front Controller / Resource Routing
+
+A very common use of mod_rewrite is to route all
+requests for non-existent resources to a single front controller script
+(e.g. index.php). This is the basis of most modern web
+framework routing.
+
+The typical mod_rewrite approach is:
+
+
+RewriteEngine On
+RewriteCond "%{REQUEST_FILENAME}" !-f
+RewriteCond "%{REQUEST_FILENAME}" !-d
+RewriteRule "^(.*)$" "/index.php" [L]
+
+
+This can be accomplished far more simply with the
+FallbackResource directive:
+
+
+FallbackResource /index.php
+
+
+FallbackResource does the
+same thing - requests for existing files and directories are served
+normally, while everything else is routed to the specified resource -
+but without the overhead and complexity of the rewrite engine. It works
+in both server configuration and .htaccess context.
+
+To disable a FallbackResource set in a parent
+directory:
+
+
+FallbackResource disabled
+
+
+
+
+Conditional Configuration with Expressions
+
+Many uses of RewriteCond
+can be replaced by the
+If directive, which
+supports a rich expression syntax and
+integrates cleanly with other Apache directives.
+
+Redirect based on a query string parameter:
+
+
+<If "%{QUERY_STRING} =~ /lang=fr/">
+ Redirect "/welcome" "/bienvenue"
+</If>
+
+
+Restrict access by request method:
+
+
+<If "%{REQUEST_METHOD} IN {'DELETE', 'PUT', 'PATCH'}">
+ Require ip 10.0.0.0/8
+</If>
+
+
+Block requests missing a Host header (HTTP/1.0 clients):
+
+
+<If "-z req('Host')">
+ Require all denied
+</If>
+
+
+See the expression evaluation
+documentation for the full syntax available in
+If blocks.
+
+
+
Forbidding Image Hotlinking