トップ> perl scripts> .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"-->
などとすればよいです。
カテゴリ内の記事
- 404ファイルが存在しないを自前で作る(2005/09/14)
- .htaccessでSSIを有効に(2005/09/24)
- HTMLのタグ変換、改行変換などのCGI/PERLスクリプト(2005/10/01)
- メール送信のcgi/perlスクリプト関数(2005/10/01)
- 配列の個数(2005/10/05)
- FTPコマンドで自動ログイン(2006/04/11)
- お気に入り追加(2006/05/02)
- 続)メールのヘッダをMIMEエンコード(2006/05/08)
- Perl Net::ftpで単純なFTP送信(2006/05/12)
- Perlでsocketのタイムアウト(2006/07/12)
