AddOutputFilterByType is deprecated in Apache.
The documentation says that the same functionality is available using mod_filter.
I currently use
AddOutputFilterByType DEFLATE text/html
What is the equivalent using mod_filter?
AddOutputFilterByType
had severe limitations in httpd-2.2
so it was marked deprecated there. But in httpd-2.4
this directive was moved to filter_module
, corrected and un-deprecated.
In apache 2.2 you should instead enable filter_module
and deflate_module
and use:
# 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
would only serve compressed content to browsers that declare support for gzip
encoding in request header.
I'm using mod_filter
for substituing instead of deflating, but the idea is the same.
This is what worked for me (I'm doing reverse proxy and rewriting urls and links):
LoadModule substitute_module modules/mod_substitute.so
LoadModule filter_module modules/mod_filter.so
FilterDeclare MYFILTER
# syntax changed in Apache2.4 (see also https://httpd.apache.org/docs/current/mod/mod_filter.html)
FilterProvider MYFILTER SUBSTITUTE "%{Content_Type} = 'text/html'"
FilterProvider MYFILTER SUBSTITUTE "%{Content_Type} = 'text/xml'"
FilterProvider MYFILTER SUBSTITUTE "%{Content_Type} = 'application/javascript'"
FilterProvider MYFILTER SUBSTITUTE "%{Content_Type} = 'application/json'"
<Location /sial/>
ProxyPass http://localhost:8300/
ProxyPassReverse http://localhost:8300/
ProxyPassReverseCookiePath / /sial/
FilterChain MYFILTER
Substitute "s|/tea_sial_v2|/sial/tea_sial_v2|inq"
</Location>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With