0

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?

Jan Hadáček
  • 83
  • 1
  • 6

1 Answers1

0

The problem was that gzip was enabled. For some strange reason, it only applied to sites processed through mod_php and not those served directly. I solved it by turning off gzip:

SetEnv no-gzip 1
AddOutputFilterByType SUBSTITUTE text/html application/x-httpd-php
Substitute "s~</body>~...PIWIK CODE...</body>~ni"

It works as a workaround, however, gzip is useful so I would like to see another solutition without turning off gzip.

Jan Hadáček
  • 83
  • 1
  • 6