简体   繁体   English

什么可能导致Apache mod_filter和mod_substitute过度替换

[英]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'. 我对下面的过滤器的意图是更改从测试目录提供的任何页面的<title>标记,并以“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? 因此,我需要更改/启用/禁用以解决此问题?

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. 我假设过滤器(如指定的那样)放置在自己的conf文件中,然后包含在具有Include指令的虚拟主机中时,仅适用于该虚拟主机。

As it turns out, the conf file was included in 4 virtual hosts and subsequently applied four times. 事实证明,conf文件包含在4个虚拟主机中,随后应用了4次。

A number of possible solutions exists depending on modularity and time behaviour goals. 根据模块化和时间行为目标,存在许多可能的解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM