1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
4 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
5 This file is generated from xml source: DO NOT EDIT
6 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
8 <title>mod_sed - Apache HTTP Server</title>
9 <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
10 <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
11 <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" />
12 <link href="../images/favicon.ico" rel="shortcut icon" /></head>
14 <div id="page-header">
15 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p>
16 <p class="apache">Apache HTTP Server Version 2.5</p>
17 <img alt="" src="../images/feather.gif" /></div>
18 <div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div>
20 <a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs/">Documentation</a> > <a href="../">Version 2.5</a> > <a href="./">Modules</a></div>
21 <div id="page-content">
22 <div id="preamble"><h1>Apache Module mod_sed</h1>
24 <p><span>Available Languages: </span><a href="../en/mod/mod_sed.html" title="English"> en </a> |
25 <a href="../fr/mod/mod_sed.html" hreflang="fr" rel="alternate" title="Français"> fr </a></p>
27 <table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>Filter Input (request) and Output (response) content using <code>sed</code> syntax</td></tr>
28 <tr><th><a href="module-dict.html#Status">Status:</a></th><td>Experimental</td></tr>
29 <tr><th><a href="module-dict.html#ModuleIdentifier">Module Identifier:</a></th><td>sed_module</td></tr>
30 <tr><th><a href="module-dict.html#SourceFile">Source File:</a></th><td>mod_sed.c sed0.c sed1.c regexp.c regexp.h sed.h</td></tr>
31 <tr><th><a href="module-dict.html#Compatibility">Compatibility:</a></th><td>Available in Apache 2.3 and later</td></tr></table>
35 <code class="module"><a href="../mod/mod_sed.html">mod_sed</a></code> is an in-process content filter. The <code class="module"><a href="../mod/mod_sed.html">mod_sed</a></code> filter implements the <code>sed</code> editing
36 commands implemented by the Solaris 10 <code>sed</code>
37 program as described in the <a href="http://docs.sun.com/app/docs/doc/816-5165/sed-1b?a=view">manual
38 page</a>. However, unlike <code>sed</code>, <code class="module"><a href="../mod/mod_sed.html">mod_sed</a></code> doesn't take data from
40 input. Instead, the filter acts on the entity data sent between client and
41 server. <code class="module"><a href="../mod/mod_sed.html">mod_sed</a></code> can be used as an input or output filter. <code class="module"><a href="../mod/mod_sed.html">mod_sed</a></code> is a
42 content filter, which means that it cannot be used to modify client or
46 The <code class="module"><a href="../mod/mod_sed.html">mod_sed</a></code> output filter accepts a chunk of data, executes the <code>sed</code> scripts on the data, and generates the output which is passed to the next filter in the chain.
50 The <code class="module"><a href="../mod/mod_sed.html">mod_sed</a></code> input filter reads the data from the next filter in the chain, executes the <code>sed</code> scripts, and returns the generated data to the caller filter in the filter chain.
54 Both the input and output filters only process the data if newline characters are seen in the content. At the end of the data, the rest of the data is treated as the last line.
57 <p>A tutorial article on <code class="module"><a href="../mod/mod_sed.html">mod_sed</a></code>, and why it is more powerful than simple
58 string or regular expression search and replace, is available <a href="http://blogs.sun.com/basant/entry/using_mod_sed_to_filter">on
59 the author's blog</a>.</p>
62 <div id="quickview"><h3 class="directives">Directives</h3>
64 <li><img alt="" src="../images/down.gif" /> <a href="#inputsed">InputSed</a></li>
65 <li><img alt="" src="../images/down.gif" /> <a href="#outputsed">OutputSed</a></li>
69 <li><img alt="" src="../images/down.gif" /> <a href="#sampleconf">Sample Configuration</a></li>
70 <li><img alt="" src="../images/down.gif" /> <a href="#sed_commands">Sed Commands</a></li>
72 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
74 <h2><a name="sampleconf" id="sampleconf">Sample Configuration</a></h2>
75 <div class="example"><h3>Adding an output filter </h3><p><code>
76 # In the following example, the sed filter will change the string<br />
77 # "monday" to "MON" and the string "sunday" to SUN in html documents<br />
78 # before sending to the client.<br />
80 <Directory "/var/www/docs/sed"> <br />
82 AddOutputFilter Sed html <br />
83 OutputSed "s/monday/MON/g" <br />
84 OutputSed "s/sunday/SUN/g" <br />
86 </Directory> <br />
90 <div class="example"><h3>Adding an input filter </h3><p><code>
91 # In the following example, the sed filter will change the string<br />
92 # "monday" to "MON" and the string "sunday" to SUN in the POST data<br />
95 <Directory "/var/www/docs/sed"> <br />
97 AddInputFilter Sed php <br />
98 InputSed "s/monday/MON/g" <br />
99 InputSed "s/sunday/SUN/g" <br />
101 </Directory> <br />
104 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
105 <div class="section">
106 <h2><a name="sed_commands" id="sed_commands">Sed Commands</a></h2>
108 Complete details of the <code>sed</code> command can be found from the
109 <a href="http://docs.sun.com/app/docs/doc/816-5165/sed-1b?a=view">sed manual
113 <dt><code>b</code></dt>
114 <dd>Branch to the label specified (similar to goto).</dd>
115 <dt><code>h</code></dt>
116 <dd>Copy the current line to the hold buffer.</dd>
117 <dt><code>H</code></dt>
118 <dd>Append the current line to the hold buffer.</dd>
119 <dt><code>g</code></dt>
120 <dd>Copy the hold buffer to the current line.</dd>
121 <dt><code>G</code></dt>
122 <dd>Append the hold buffer to the current line.</dd>
123 <dt><code>x</code></dt>
124 <dd>Swap the contents of the hold buffer and the current line.</dd>
127 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
128 <div class="directive-section"><h2><a name="InputSed" id="InputSed">InputSed</a> <a name="inputsed" id="inputsed">Directive</a></h2>
129 <table class="directive">
130 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sed command to filter request data (typically <code>POST</code> data)</td></tr>
131 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>InputSed <var>sed-command</var></code></td></tr>
132 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>directory, .htaccess</td></tr>
133 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Experimental</td></tr>
134 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_sed</td></tr>
136 <p>The <code class="directive">InputSed</code> directive specifies the <code>sed</code> command
137 to execute on the request data e.g., <code>POST</code> data.
141 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
142 <div class="directive-section"><h2><a name="OutputSed" id="OutputSed">OutputSed</a> <a name="outputsed" id="outputsed">Directive</a></h2>
143 <table class="directive">
144 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sed command for filtering response content</td></tr>
145 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>OutputSed <var>sed-command</var></code></td></tr>
146 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>directory, .htaccess</td></tr>
147 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Experimental</td></tr>
148 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_sed</td></tr>
150 <p>The <code class="directive">OutputSed</code> directive specifies the <code>sed</code>
151 command to execute on the response.
156 <div class="bottomlang">
157 <p><span>Available Languages: </span><a href="../en/mod/mod_sed.html" title="English"> en </a> |
158 <a href="../fr/mod/mod_sed.html" hreflang="fr" rel="alternate" title="Français"> fr </a></p>
159 </div><div id="footer">
160 <p class="apache">Copyright 2012 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
161 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div>