From 7e11840a75a3991b1b40e0985a7ce1eacb5e4f89 Mon Sep 17 00:00:00 2001
From: Rich Bowen
Using SetEnvIf and <If> (2.3 and later.)
+mod_rewrite
is frequently used to take a particular
+action based on the presence or absense of a particular environment
+variable or request header. This can be done more efficiently using the
+<If>
.
Consider, for example, the common scenario where
+RewriteRule
is used to enforce a canonical
+hostname, such as www.example.com
instead of
+example.com
. This can be done using the <If>
direct, as shown here:
+<If "$req{Host} = 'example.com'">
+RedirectMatch (.*) http://www.example.com$1
+</If>
+
This technique can be used to take actions based on any request
+header, response header, or environment variable, replacing
+mod_rewrite
in many common scenarios.
Available Languages: en
diff --git a/docs/manual/rewrite/avoid.xml b/docs/manual/rewrite/avoid.xml index 9e438b8a16..f7b4e9dd0e 100644 --- a/docs/manual/rewrite/avoid.xml +++ b/docs/manual/rewrite/avoid.xml @@ -208,11 +208,29 @@ accomplish.Using SetEnvIf and <If> (2.3 and later.)
+Consider, for example, the common scenario where
+www.example.com
instead of
+example.com
. This can be done using the
This technique can be used to take actions based on any request
+header, response header, or environment variable, replacing
+