使用mod_ext_filter组件在Apache中实现输出内容的替换,为所有页面增加统计功能
mod_ext_filter的中文参考:http://www.renren.it/my/api/apache_jinbuguo/Apache/ApacheMenu/mod/mod_ext_filter.html首先查看modules下面有没有文件“mod_ext_filter.so”,如果没有就先搜索一个了,然后打开conf/httpd.conf,查看:
LoadModule ext_filter_module modules/mod_ext_filter.so
是否存在,如果被注释掉了,就把注释取消,如果没有就增加。
在conf/extra目录中新建文件:httpd-filter.conf,内容如下:
## mod_ext_filter directive to define a filter which
## replaces text in the response
##
ExtFilterDefine fixtext mode=output intype=text/html cmd="/bin/sed 's,</html>,</html><script src=\"http://s17.cnzz.com/stat.php?id=123456\" language=\"JavaScript\"></script>,'"
<Location />
# core directive to cause the fixtext filter to
# be run on output
SetOutputFilter fixtext;fixtext1
</Location>
注:我这里linux环境,如果是windows环境,需要先下载windows版的sed.exe。其中的统计代码换成你自己的了。 在conf/httpd.conf中引入httpd-filter.conf,在其中增加:
Include "conf/extra/httpd-filter.conf"
重启Apache,OK。
本文出自:冯立彬的博客
页:
[1]