滅多に使うことが無いけど、使うときも無いでも無いということでメモ。 あんまりApacheのバージョン間で大きな違いはないけど、一応バージョンごとのドキュメントURL: - http://httpd.apache.org/docs/1.3/mod/mod_include.html - http://httpd.apache.org/docs/2.0/mod/mod_include.html - http://httpd.apache.org/docs/2.2/mod/mod_include.html おまけ:IIS/5.0, 6.0系のSSI - http://www.atmarkit.co.jp/fwin2k/win2ktips/765iis5ssi/iis5ssi.html - http://www.atmarkit.co.jp/fwin2k/win2ktips/766iis6ssi/iis6ssi.html - http://www.atmarkit.co.jp/fwin2k/win2ktips/206actiis/actiis.html - http://msdn.microsoft.com/en-us/library/ms525185(v=VS.90).aspx 以下、Apache 2.x系での実験。 #more|| PHPの出力にSSIを適用する。SSIがフィルタとして使えるようになったのは2.0以降のようなので、1.3系は無理かも。あとIISの場合もASPに同時にSSIを適用できないようなので、同様に無理かも。 httpd.conf: LoadModule include_module modules/mod_include.so ... AddType text/html .php .html AddOutputFilter INCLUDES .php .html /ssi01/foo.html: #pre||> foo





||< /ssi01/foo.html: foo /ssi01/bar.php: bar\n"; /ssi01/.htaccess: Options Includes t01.htmlの実行結果: #pre||> foo foobar
foo
foo
bar 
bar 
HTTP_HOST=localhost
...
DOCUMENT_NAME=t01.html
||< .htaccessにIncludesNOEXECを加えてみる: Options Includes IncludesNOEXEC t01.htmlの実行結果: #pre||> foo foobar
[an error occurred while processing this directive]
[an error occurred while processing this directive]
[an error occurred while processing this directive]
[an error occurred while processing this directive]
HTTP_HOST=localhost
...
DOCUMENT_NAME=t01.html
||< ドキュメント上では、IncludesNOEXECではexecコマンドが無効化+includeでtext系MIMEのファイル以外はNG、となるので、foo.htmlのincludeは動くかと思われたが、includeが全滅してしまった。 PHPとかも動いているので、内部的にtext MIME型として処理されなかったのかもしれない。 そこで、 /ssi01/baz.css: div.id01 { color: red; } を用意し、t01.htmlに を加えてみたところ、IncludesNOEXECが有効でもHTML上にcssの内容が展開された。これによりtext系MIMEが展開されることを確認できた。逆に言えばPHPなど内部でAddTypeするなどしてMIMEを弄っている場合は上手くincludeできない可能性が高い。