AddOutputFilterByType在 Apache 中已弃用。
文档说使用 mod_filter 可以使用相同的功能。 .
我目前使用
AddOutputFilterByType DEFLATE text/html
什么是等效使用 mod_filter ?
最佳答案
AddOutputFilterByType
在 httpd-2.2
中存在严重限制所以它在那里被标记为已弃用。但在 httpd-2.4
此指令已移至 filter_module
,已更正且未弃用。
在 apache 2.2 中,您应该启用 filter_module
和 deflate_module
并使用:
# Declare a "gzip" filter, it should run after all internal filters like PHP or SSI
FilterDeclare gzip CONTENT_SET
# "gzip" filter can change "Content-Length", can not be used with range requests
FilterProtocol gzip change=yes;byteranges=no
# Enable "gzip" filter if "Content-Type" contains "text/html", "text/css" etc.
FilterProvider gzip DEFLATE resp=Content-Type $text/html
FilterProvider gzip DEFLATE resp=Content-Type $text/css
FilterProvider gzip DEFLATE resp=Content-Type $text/javascript
FilterProvider gzip DEFLATE resp=Content-Type $application/javascript
FilterProvider gzip DEFLATE resp=Content-Type $application/x-javascript
# Add "gzip" filter to the chain of filters
FilterChain gzip
deflate_module
只会向声明支持 gzip
的浏览器提供压缩内容请求头中的编码。
关于Apache AddOutputFilterByType 已弃用。如何使用 mod_filter 重写?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5230202/