您的位置:首页 > 运维架构 > Apache

使用mod_ext_filter组件在Apache中实现输出内容的替换,为所有页面增加统计功能

2012-06-29 16:36 1451 查看
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。

本文出自:冯立彬的博客
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐