mod_line_edit is a general-purpose filter for text documents. It operates as a simple on-the-fly line editor, applying search-and-replace rules defined in a configuration or .htaccess file.
Unlike most of WebÞing's filter modules, it is not markup-aware, so it is not an optimal choice for processing HTML or XML, though it may nevertheless be used with caution (and may be far better than semi-markup-aware options such as mod_layout).
mod_line_edit is written for performance and reliability, and should scale without problems as document size grows. mod_line_edit is fully compatible with Apache 2.0 and 2.2, and all operating systems and MPMs.
When mod_line_edit was first written, it was unique in its class. This is no longer the case. A similar module mod_substitute is included in recent Apache versions, and the state-of-the-art is Basant Kukreja's mod_sed.
LoadModule line_edit_module modules/mod_line_edit.so
The module implements a single output filter named
Insert it in the filter chain using the standard filter directives,
e.g. to rewrite all text documents:
FilterProvider textedit line-editor resp=Content-Type $text/ FilterChain textedit
or, for backward compatibility with Apache 2.0:
AddOutputFilter line-editor .txt .css .js
LERewriteRule directive defines search-and-replace rules.
Both simple text and regular expression search and replace are supported.
mod_line_edit normally applies its edits line-by-line. This avoids the risk of missing a pattern to be matched because it is spread over more than one chunk of data when it reaches the parser, without having to resort to the performance and scalability limitations of loading an entire document into memory.
If the LineEdit environment variable is set, it controls Content Types that will be filtered. This enables it to filter selectively on content-type in a proxy with Apache 2.0. Just set the variable to a list of content types, and mod_line_edit will leave other types untouched.
This also works with Apache 2.2, but is of course unnecessary there.
LELineEnd UNIX|MAC|DOS|NONE|ANY|CUSTOM [char]
This tells the parser what characters in the text to interpret as line-endings:
\r. Note that modern MacOSX is Unix-based.
\r\ntreated as one, not two, linebreaks). This is the default.
When you use
LELineEnd Custom, you must specify a second
single-character argument, which is the character to split the input on.
For all other
LELineEnd options, any second argument will
LERewriteRule from-pattern to-pattern [flags]
This directive defines a search-and-replace edit rule that will be applied to the text.
Registered Users may request binaries for any available platform.
Dec. 26th 2005: the first public release of mod_line_edit is version 0.9.2
June 12th 2006: added capability to interpolate environment variables in rewrite rules. Bumping version to 1.0 because 0.9 has proved stable over six months in the wild.