使用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。


本文出自:冯立彬的博客







  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值