mod_filter

Overview

mod_filter module provides selective filter application depending on the content type.

Quick start

Compression for all php files

#put it in the root .htaccess
<Files *.php >
    FilterChain +gzip
</Files *.php >

Related articles and topics

Directives

Name Context Description
FilterChain S V D .h configures the filter chain
FilterDeclare S V D .h currently not supported
FilterProtocol S V D .h currently not supported
FilterProvider S V D .h registers a content filter
FilterTrace S V D .h currently not supported

FilterChain

FilterChain directive builds up a filter chain out of specified filters. FilterChain may take any number of arguments, each of which may be preceded by a special character saying what should be done with the filter:

Syntax

FilterChain [+=-@!]filter-name ...
+filter-name Add filter-name to the end of the filter chain
@filter-name Insert filter-name at the start of the filter chain
-filter-name Remove filter-name from the filter chain
=filter-name Empty the filter chain and insert filter-name
! Empty the filter chain
filter-name Equivalent to +filter-name

Example

#setup complex filters
FilterChain HotLink LinkFreeze gzip

Example

#setup complex filters
<Files *.php >
    FilterChain +HotLink 
    FilterChain +LinkFreeze 
    FilterChain +gzip
</Files *.php >

FilterDeclare

Currently not supported.

FilterProtocol

Currently not supported.

FilterProvider

FilterProvider directive registers a provider for the filter. The provider will be called only in case the declared match matches the value of header or environment variable declared as dispatch .

Syntax

FilterProvider filter-name provider-name   [req|resp|env]=dispatch match

Description

  • provider-name is registered by loading a module that registers the name with ap_register_output_filter.
  • dispatch argument is a string with optional req=, resp= or env= prefix causing it to respectively dispatch on the request header, response header, or environment variable named. If no prefix is specified, by default response header is used. A special case is the word handler , which causes mod_filter to dispatch on the content handler.
  • match argument specifies a match that will be applied to the filter's dispatch criterion. The match may be a string match (exact or substring), a regex , an integer (greater, less than or equals), or unconditional. The starting characters of match string define:
    First character : if the first character is an exclamation mark (!), this reverses the rule, so the provider will be used only in case the match fails .
    Second character : it interprets the first character excluding any leading ! as follows:
    Character Description
    (none) exact match
    $ substring match
    / regex match (delimited by a second /)
    = integer equality
    < integer less-than
    <= integer less-than or equal
    > integer greater-than
    >= integer greater-than or equal
    * Unconditional match

Example

#enable gzip compression for all text/* and image/* types
FilterProvider iZip  gzip Content-Type $text/               
FilterProvider iZip  gzip Content-Type /image/.*/
SetEnv iZip

FilterTrace

Currently not supported.