Cent Os 6.4 で .htaccess が動作しない

Cent Os 6.4 で .htaccess が動作しない

Cent Os 6.4 -Final Version をインストールし、PHP Web 開発用の環境を設定しました。

私のアプリケーションは、URL の書き換えとファイルへの直接アクセスの拒否に .htaccess を使用します。

私のhttpdの設定ファイル - /etc/httpd/conf/httpd.conf は以下の通りです。

<Directory "/var/www/html">

#
# Possible values for the Options directive are "None", "All",
# or any combination of:
#   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important.  Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
    Options Indexes FollowSymLinks

#
# 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
#
    AllowOverride None

#
# Controls who can get stuff from this server.
#
    Order allow,deny
    Allow from all

</Directory>

私が上書きを許可しないすべて上書きを許可認証を求められます。私の場合はうまくいかず、以下のようなエラーが出ました。

This server could not verify that you are authorized to access the document requested.

間違った資格情報(例:パスワードが間違っている)を入力したか、ブラウザが必要な資格情報の入力方法を理解していません。

私の.htaccessは次のようになります。

deny from all

答え1

AllowOverride Nonehttpd.conf の設定により、 .htaccess ファイルは完全に無視されます。そのため、その設定を変更する必要があります。

.htaccess ファイルが許可されている場合、Apache は DocumentRoot から下の各ディレクトリで .htaccess ファイルの存在を確認し、そこに設定を適用してから、次のディレクトリとそこにある .htaccess ファイルに移動します。

たとえば、./www/.htaccess「すべてを拒否」に設定されている場合、/scripts/test/hello-world.php にアクセスしようとする訪問者は、 ./www/scripts/test/.htaccess「すべてを許可」に設定されている可能性にもかかわらず拒否されます。

したがって、認証を要求しているのが PHP スクリプトではない場合は、上位レベルのディレクトリで .htaccess ファイルを確認することをお勧めします。

関連情報