mod_deflate がこのシナリオに飛び込むのを防ぐのに問題があります:
- CodeIgniter (または index.php にリダイレクトするその他のフレームワーク) を実行しているユーザー
- mod_deflate がアクティブです
- zip ファイルは CodeIgniter コントローラーによって提供されます (ヘッダー + readfile)
問題は、Apache が常にコンテンツを存在するものとして検出するため、サーバーが ZIP ファイルを PHP ファイルであると想定するため、以下の行のphp
ようなものが機能しないことです。
<FilesMatch "\.(xml|txt|html|php)$">
SetOutputFilter DEFLATE
</FilesMatch>
同じフレームワーク ファイルによって生成された HTML ファイルまたは ZIP ファイルと Apache を区別する方法についてのアイデアindex.php
。
編集:
Apacheログ
[Mon Jun 20 02:14:19 2011] [debug]
mod_deflate.c(602): [client 192.168.0.5]
Zlib: Compressed 50870209 to 50878224 : URL /index.php,
referer: http://demo.dev/
編集:
zipを提供するCIコントローラー
header('Content-Type: application/zip');
header('Content-Transfer-Encoding: binary');
header("Content-Length: " . filesize($file_location));
header('Content-Disposition: attachment; filename="' . $file_title . '"');
readfile($file_location);