.htaccess - mod_filter
FilterChain ディレクトリ
FilterChain ディレクトリは、filter-name
で宣言したフィルタによる、フィルタチェインを設定します。本ディレクティブでは、任意の数の引数を設定できます。各引数には、動作を制御する頭文字 +
、=
、-
、@
、!
を付けることができます。
# FilterChain ディレクティブの構文
FilterChain [+=-@!]filter-name ...
値 | 説明 |
---|---|
+filter-name | filter-name をフィルタ・チェインの末尾に追加します。 |
@filter-name | filter-name をフィルタ・チェインの先頭に追加します。 |
-filter-name | filter-name をフィルタ・チェインから取り除きます。 |
=filter-name | フィルタ・チェインを空にし、filter-name を追加します。 |
! | フィルタ・チェインを空にします。 |
filter-name | +filter-name と同じです。 |
FilterDeclare ディレクトリ
FilterDeclare ディレクトリは、出力フィルタの実行タイミングを指定できます。指定時には、ヘッダ、または環境変数を同時に宣言します。
以下の構文の filter-name
には、FilterProvider、FilterChain、FilterProtocol ディレクティブで使うためのフィルタ名を指定します。[type]
には、RESOURCE、CONTENT_SET、PROTOCOL、TRANSCODE、CONNECTION、NETWORK のいずれかを指定します。指定しない場合は、RESOURCE がデフォルト値となります。
# FilterDeclare ディレクティブの構文
FilterDeclare filter-name [type]
フィルタのタイプ ([type]
) は、ap_filter_type の値をとります。ap_filter_type は util_filter.h に含まれる enum 変数です。フィルタのタイプは、内部で固有の並び順を持ち、フィルタチェインの順序を決定しています。
/**
* Filters have different types/classifications. These are used to group
* and sort the filters to properly sequence their operation.
*
* The types have a particular sort order, which allows us to insert them
* into the filter chain in a determistic order. Within a particular
* grouping, the ordering is equivalent to the order of calls
* to ap_add_*_filter().
*/
typedef enum {
/** These filters are used to alter the content that is passed through
* them. Examples are SSI or PHP. */
AP_FTYPE_RESOURCE = 10,
/** These filters are used to alter the content as a whole, but after all
* AP_FTYPE_RESOURCE filters are executed. These filters should not
* change the content-type. An example is deflate. */
AP_FTYPE_CONTENT_SET = 20,
/** These filters are used to handle the protocol between server and
* client. Examples are HTTP and POP. */
AP_FTYPE_PROTOCOL = 30,
/** These filters implement transport encodings (e.g., chunking). */
AP_FTYPE_TRANSCODE = 40,
/** These filters will alter the content, but in ways that are
* more strongly associated with the connection. Examples are
* splitting an HTTP connection into multiple requests and
* buffering HTTP responses across multiple requests.
*
* It is important to note that these types of filters are not
* allowed in a sub-request. A sub-request's output can certainly
* be filtered by ::AP_FTYPE_RESOURCE filters, but all of the "final
* processing" is determined by the main request. */
AP_FTYPE_CONNECTION = 50,
/** These filters don't alter the content. They are responsible for
* sending/receiving data to/from the client. */
AP_FTYPE_NETWORK = 60
} ap_filter_type;
FilterProtocol ディレクトリ
FilterProtocol ディレクトリは、フィルタを実行しないように設定できます。また、フィルタの効果を考慮して HTTP レスポンスヘッダを正しく設定したりするように mod_filter が振る舞うようにします。
# FilterProtocol ディレクティブの構文
FilterProtocol filter-name [provider-name] proto-flags
値 | 説明 |
---|---|
change=yes | フィルタは、コンテンツ、およびコンテンツの長さの変更を許可します。 変更を許可しない no の設定は Apache 2.4.7 以降で使用可能です。 |
change=1:1 | フィルタは、コンテンツの変更を許可しますが、コンテンツの長さの変更は許容しません。 |
byteranges=no | フィルタは、byteranges 上で動作せず、完全な入力を要求します。 |
proxy=no | フィルタは、プロキシコンテンツについて実行しません。 |
proxy=transform | フィルタは、Cache-Control: no-transform ヘッダと互換性のないレスポンスを返します。 |
cache=no | フィルタは、キャッシュが不可能な出力を行います。 |
FilterProvider ディレクトリ
FilterProvider ディレクトリは、スマートフィルタのプロバイダを登録します。プロバイダは、match
の文字列と一致した場合、または dispatch
の値が一致したときに呼ばれます。
# FilterProvider ディレクティブの構文
FilterProvider filter-name provider-name [req|resp|env]=dispatch match
dispatch
は、req=
(リクエスト) 、resp=
(レスポンス) 、env=
(環境変数) を意味するプレフィックスを設定できます。プレフィックスを省略した場合は、デフォルトでレスポンスとなります。
match
は、フィルタの dispatch
で指定したプレフィックスの設定値に一致する文字列を指定できます。指定できる文字列は、完全一致、部分一致、正規表現、整数、無条件一致のいずれかになります。match
の処理順は、最初に先頭文字列が !
(否定) の条件であるかを判定します。次に、否定以外の先頭文字列を判定します。否定以外の先頭文字列として、以下の記号が使用可能です。
値 | 説明 |
---|---|
(なし) | 完全一致 |
$ | 部分一致 |
/ | 正規表現 (次の / で区切られます) |
= | 比較対象の整数と等価であるか |
< | 比較対象の整数未満であるか |
<= | 比較対象の整数以下であるか |
> | 比較対象の整数を超えるか |
>= | 比較対象の整数以上であるか |
* | 無条件一致 |
関連記事
- .htaccess - コア機能
- .htaccess - mod_actions
- .htaccess - mod_alias
- .htaccess - mod_auth_basic
- .htaccess - mod_authn_default
- .htaccess - mod_authn_file
- .htaccess - mod_authz_default
- .htaccess - mod_authz_groupfile
- .htaccess - mod_authz_host
- .htaccess - mod_authz_user
- .htaccess - mod_autoindex
- .htaccess - mod_env
- .htaccess - mod_expires
- .htaccess - mod_headers
- .htaccess - mod_imagemap
- .htaccess - mod_include
- .htaccess - mod_mime
- .htaccess - mod_negotiation
- .htaccess - mod_setenvif
- .htaccess - mod_dir
- .htaccess - mod_rewrite