The essence mod_substitute is to replace the text in the body of the response from the web server. With it you can change for example links to one domain with links to another domain without interfering with the site code.
You can check if the module is loaded like this:
/usr/sbin/apachectl -t -D DUMP_MODULES 2>&1|grep subst
Or make sure the following line is present and not commented out in the httpd.conf file:
LoadModule substitute_module modules/mod_substitute.so
Let’s say you have a website with the domain name
mysite.com. You need to make the site
dev.mysite.com out of it, but there are links to the
mysite.com hardcoded in the database and website files.
There is an option to update the database and files but you can go the path of least resistance and add the following construction to .htaccess:
AddOutputFilterByType SUBSTITUTE text/html Substitute "s|mysite.com|dev.mysite.com|in" Substitute "s|www.mysite.com|dev.mysite.com|in"
The first line indicates the type of files that will be replaced.
If you also have customized scripts, make the server process them including:
In case of problems, check Apache site settings. Pay attention to:
Substitute is sensitive to the
Accept-Ranges header. In case of problems try adding the following to the
Substitute construct in your
Header set Accept-Ranges "none"