GCS Amplitude
GCS Amplitude

Apache Module mod_substitute

"foo=k,bar=k" -> "foo/bar=k" Substitute "s|foo=(\w+),bar=\1|foo/bar=$1"

provides a mechanism to perform both regular expression and fixed string substitutions on response bodies.mod_substitute

Substitute s/pattern/substitution/[infq]

directive specifies a search and replace pattern to apply to the response body.

The meaning of the pattern can be modified by using any combination of these flags:

flag forces the pattern to be treated as a fixed string.f

flag causes mod_substitute to flatten the result of a substitution allowing for later substitutions to take place on the boundary of this one. This is the default.q

flag causes mod_substitute to not flatten the buckets after each substitution. This can result in much faster response and a decrease in memory utilization, but should only be used if there is no possibility that the result of one substitution will ever match a pattern or regex of a subsequent one. AddOutputFilterByType SUBSTITUTE text/html Substitute s/foo/bar/ni

If either the pattern or the substitution contain a slash character then an alternative delimiter should be used:

Backreferences can be used in the comparison and in the substitution, when regular expressions are used, as illustrated in the following example:

A common use scenario for mod_substitute

is the situation in which a front-end server proxies requests to a back-end server which returns HTML with hard-coded embedded URLs that refer to the back-end server. These URLs don't work for the end-user, since the back-end server is unreachable.

In this case, mod_substutite

can be used to rewrite those URLs into something that will work from the front end:

ProxyPass /blog/ http://internal.blog.example.com ProxyPassReverse /blog/ http://internal.blog.example.com/ Substitute "s|http://internal.blog.example.com/|http://www.example.com/blog/|i"

(redirect) headers that are sent by the back-end server, and, in this example, Substitute

takes care of the rest of the problem by fixing up the HTML response as well.

Modules | Directives | FAQ | Glossary | Sitemap

Apache HTTP Server Version 2.4

Modules

Modules | Directives | FAQ | Glossary | Sitemap

Apache Module mod_substitute

Available Languages: en | fr

en

Available Languages: en | fr

Apache License, Version 2.0

Copyright 2014 The Apache Software Foundation.Licensed under the Apache License, Version 2.0.