mod_substitute - Apache HTTP Server

Apache HTTP Server Version 2.2

Apache > HTTP Server > Documentation > Version 2.2 > Modules

# Apache Module mod_substitute

Available Languages: en

Description: | Perform search and replace operations on response bodies
Status: | Extension
Module Identifier: | substitute_module
Source File: | mod_substitute.c

### Summary

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

### Directives

## Substitute Directive

Description: | Pattern to filter the response content
Syntax: | `Substitute s/pattern/substitution/[inf]`
Context: | directory, .htaccess
Override: | FileInfo
Status: | Extension
Module: | mod_substitute

The `Substitute` 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:

`i`
  Perform a case-insensitive match.
`n`
  By default the pattern is treated as a regular expression. Using the `n` flag forces the pattern to be treated as a fixed string.
`f`
  The `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.

### Example

`<Location /> AddOutputFilterByType SUBSTITUTE text/html
Substitute s/foo/bar/ni
</Location>`

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

### Example of using an alternate delimiter

`<Location /> AddOutputFilterByType SUBSTITUTE text/html
Substitute "s|<BR */?>|<br />|i" </Location>`

Available Languages: en