使用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,内容如下:
注:我这里linux环境,如果是windows环境,需要先下载windows版的sed.exe。其中的统计代码换成你自己的了。
在conf/httpd.conf中引入httpd-filter.conf,在其中增加:
Include "conf/extra/httpd-filter.conf"
重启Apache,OK。
本文出自:冯立彬的博客
首先查看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。
本文出自:冯立彬的博客
相关文章推荐
- 静态页面html、shtml增加动态内容 使用apache ssi
- 关于Apache mod_rewrite的中文配置、使用和语法介绍(实现URL重写和防盗链功能)
- 关于Apache mod_rewrite的中文配置、使用和语法介绍(实现URL重写和防盗链功能)
- nginx使用replace-filter-nginx-module实现内容替换
- nginx使用replace-filter-nginx-module实现内容替换的示例
- iPhone开发之UIScrollView滚动组件的使用(三) 拖线实现按钮控制大图移动之contentInsets增加内容边距
- paip.输出内容替换在Apache 过滤器filter的设置
- paip.输出内容替换在Apache 过滤器filter的设置
- Extjs4.2 TabPanel中使用Ext.ux.IFrame组件加载内容页面
- 关于Apache mod_rewrite的中文配置、使用和语法介绍(实现URL重写和防盗链功能)
- 使用filter拦截servlet和jsp页面的内容,进行过滤后输出
- 使用JSP相关元素实现页面内容输出
- 使用filter对项目中所有页面实现字符集设置
- 技巧和诀窍:使用ASP.NET 2.0 输出缓存替换的功能实现“甜圈缓存(Donut Caching)”
- 在Apache和Nginx反向代理中实现输出内容替换
- 技巧和诀窍:使用ASP.NET 2.0 输出缓存替换的功能实现“甜圈缓存(Donut Caching)”
- 使用ASP.NET 2.0 输出缓存替换的功能实现Donut Caching
- 关于Apache mod_rewrite的中文配置、使用和语法介绍(实现URL重写和防盗链功能)
- Spring MVC_HandlerInterceptorAdapter的使用(不仅可实现Filter的所有功能,还可以更精确的控制拦截精度)
- 实现功能要求统计图书的总价,编写方法查询出在50元以上的所有图书,使用排序接口图书按照价格排序(升序排序)