I'm trying to configure my server to automatically insert a tracking code (Piwik) to all pages served. I'm using both static sites and some PHP sites. I've used the following method found on Piwik forums, which is based on mod_filter and replacements.
AddOutputFilterByType SUBSTITUTE text/html application/x-httpd-php
Substitute "s~</body>~...PIWIK CODE...</body>~ni"
However, it only works for plain HTML pages. I've tried various MIMEs for PHP, like text/php or application/x-httpd-php5, but no avail. The PHP page never gets modified by the filter, while there are no problems with HTML page.
I'm starting to think that perhaps mod_php is somehow by-passing mod_filter replacements?