From 2a463b3cd73c32ee9dcd508248d0194923f435f4 Mon Sep 17 00:00:00 2001
From: Stefan Fritsch /one/three/four.html
.
To redirect http
URLs to https
, do the
following:
-<VirtualHost *:80> +<VirtualHost *:80> ServerName www.example.com Redirect / https://www.example.com/ </VirtualHost > @@ -99,8 +98,7 @@ following: <VirtualHost *:443> ServerName www.example.com # ... SSL configuration goes here -</VirtualHost > -+</VirtualHost >
The use of RewriteRule
to perform this task may be
@@ -166,27 +164,21 @@ seems like the right approach.
RewriteRule
provides the [P] flag to pass rewritten URIs through
mod_proxy
.
-RewriteRule ^/?images(.*) http://imageserver.local/images$1 [P] -+
RewriteRule ^/?images(.*) http://imageserver.local/images$1 [P]
However, in many cases, when there is no actual pattern matching
needed, as in the example shown above, the ProxyPass
directive is a better choice.
The example here could be rendered as:
-ProxyPass /images/ http://imageserver.local/images/ -+
ProxyPass /images/ http://imageserver.local/images/
Note that whether you use RewriteRule
or ProxyPass
, you'll still need to use the
ProxyPassReverse
directive to
catch redirects issued from the back-end server:
-ProxyPassReverse /images/ http://imageserver.local/images/ -+
ProxyPassReverse /images/ http://imageserver.local/images/
You may need to use RewriteRule
instead when there are
@@ -209,11 +201,9 @@ variable or request header. This can be done more efficiently using the
hostname, such as www.example.com
instead of
example.com
. This can be done using the <If>
directive, as shown here:
-<If "req('Host') != 'www.example.com'"> +<If "req('Host') != 'www.example.com'"> Redirect / http://www.example.com/ -</If> -+</If>
This technique can be used to take actions based on any request @@ -246,7 +236,7 @@ var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/avoid.html'; } })(window, document); //-->