前提:apache2.x(ソースからコンパイル)



要件:存在しないドキュメント(HTMLやCGI等)にリクエストがあった場合に、

   任意のページに遷移させる。



① httpd.confの設定を変更します。


  AccessFileName .htaccess


  # AllowOverride controls what directives may be placed in .htaccess files.
  # It can be "All", "None", or any combination of the keywords:
  # Options FileInfo AuthConfig Limit Indexes
  #

  AllowOverride All
  


② 該当ディレクトリに.htaccessというファイルを作成します。

  で、ファイルの中に


  ErrorDocument 404 http://www.xxxxx.co.jp/error.html


  と記載します。

  ※実行権限は644以上で。



③ apacheの再起動


  /usr/local/apache2/bin/apachectl restart


 

これで、当該のファイルが存在しない場合は、

http://www.xxxxx.co.jp/error.html へリクエストが転送されます。



.htaccessファイルはサブディレクトリにも配置可能です。

親ディレクトリに.htaccessが存在する場合は

サブディレクトリの内容がOverrideされて使用されます。