apachesubstitutionmod-filter

What might be causing excess substitutions with Apache mod_filter and mod_substitute


My intention with the filter below is to change the <title> tag of any page served from a test directory to be prefixed with the word 'Test'. So

<TITLE>Foo Bar Report</TITLE>

would be replaced with

<TITLE>Test Foo Bar Report</TITLE>

The filter is:

<Directory ~ "/local/test/\w+/(bin|htdocs|perl|sql)/">
    FilterDeclare DECLARE_TEST CONTENT_SET
    FilterProvider DECLARE_TEST SUBSTITUTE "%{CONTENT_TYPE} =~ m|^text/html|"
    FilterChain DECLARE_TEST
    Substitute "s/(^\s*<TITLE>|pagetitle=|script=.*&title=)/$1T:/i"
</Directory>

Something in the configuration is causing the output to be

<TITLE>Test Test Test Test Foo Bar Report</TITLE>

Thus the filter appears to have been applied four times rather than the intended single time.

What, elsewhere in my configuration, might be causing this to occur? And therefore what do I need to change/enable/disable to remove this problem?


Solution

  • The cause of this issue was that I had made an incorrect assumption.

    I assumed that the filter, as specified, when placed in its own conf file and then included in a virtual host with the Include directive would apply to that virtual host only.

    As it turns out, the conf file was included in 4 virtual hosts and subsequently applied four times.

    A number of possible solutions exists depending on modularity and time behaviour goals.