DEV.MD / Developer Network
Search:     Advanced search
Browse by category:
Glossary | Contact Us

Install and enabling Apache mod_substitute

Add comment
Views: 1976
Votes: 2
Comments: 0
Posted: 21 Jan, 2009
by: Zavadschi S.
Updated: 21 Jan, 2009
by: Zavadschi S.

There is an interesting module for apache which does automatic search and replacement operations using regular expressions. For information about this module documented in apache website

NOTE: This module is only available in Apache 2.2.7 and later

The mod_substitute.so does not come preinstalled under modules so you have to copy the source of mod_substitute.c from the latest apache source and then compile it with apxs installer.

Download the latest apache source tarball from httpd.apache.org. you need not compile it if has already been installed.


tar zxf httpd-2.2.9.tar.gz
cd modules/filters
cp mod_substitute.c /tmp

then compile and install with apxs

apxs -cia mod_substitute.c

then open /etc/conf/httpd.conf and add a line like this…

LoadModule substitute_module modules/mod_substitute.so

This this is done, you have to setup mod_subsitute to do the filtering.

In .htaccess add lines like

AddOutputFilterByType SUBSTITUTE text/html
Substitute s/foo/bar/ni

or in httpd.conf
AddOutputFilterByType SUBSTITUTE text/html
Substitute s/foo/bar/ni
Others in this Category
document Using Cron
document Lunching KDE Control Panel Modules from command line
document Subversion - the quick start guide
document SSL - Generate self signed certificates
document Back-up data using rsync
document Search for text in binary files
document Recursively chmod only directories or files



RSS