携帯・ビジネスブログ・CGIスクリプト-htaccessを使えば色々な制御が可能になります。今回はよく使うSSIを。

トップCGI perl スクリプト/SSI> .htaccessでSSIを有効に

.htaccessでSSIを有効に

htaccessを使えば色々な制御が可能になります。今回はよく使うSSIを。

1..htaccessは使えないかもしれない。

  プロバイダにより、利用の可否は違うので、問い合わせてみてください。
  とりあえず、apacheの場合は、コンフィグファイルhttpd.conf


# This should be changed to whatever you set DocumentRoot to.
#
<Directory "/Library/WebServer/Documents">
#
# This may also be "None", "All", or any combination of "Indexes",
# "Includes", "FollowSymLinks", "ExecCGI", or "MultiViews".
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
Options ExecCGI Indexes FollowSymLinks MultiViews
#
# This controls which options the .htaccess files in directories can
# override. Can also be "All", or any combination of "Options", "FileInfo",
# "AuthConfig", and "Limit"
#
AllowOverride All
#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all
</Directory>


のAllowOverrideがどうなっているかです。
  (#はコメント)


2.拡張子htmlでもSSIが動くようにするには?

  .htaccessファイルに以下を記述します。
   AddType text/html .html
   AddHandler server-parsed .html

  ついでに、OptionにIndexesが指定されているとブラウザから丸見えになる可能性があるので
   Options -Indexes
  も追加しておいたほうがよいでしょう。


3.そうすれば、HTMLのなかで

  ファイルのインクルードは
   <!--#include virtual="./ssi/header.html"-->
  とすれば、header.htmlが読み込まれ、
  SSI/CGIを動かそうとすれば
   <!--#exec cmd="./ssi/counter.cgi"-->
  などとすればよいです。

related articles