
Cent Os 6.4 -Final Version을 설치하고 PHP 웹 개발을 위한 환경을 설정했습니다.
내 응용 프로그램은 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>
내가 변경했을 때AllowOverride 없음에게모두 무시 허용, 인증을 요청합니다. 그래서 그것은 나를 위해 작동하지 않으며 아래와 같이 오류가 발생했습니다.
This server could not verify that you are authorized to access the document requested.
잘못된 자격 증명(예: 잘못된 비밀번호)을 제공했거나 브라우저가 필요한 자격 증명을 제공하는 방법을 이해하지 못합니다.
내 .htaccess는 다음과 같습니다.
deny from all
답변1
AllowOverride None
httpd.conf의 설정을 사용하면 .htaccess 파일이 완전히 무시됩니다. 그래서 해당 설정을 변경해야 합니다.
.htaccess 파일이 허용되면 Apache는 DocumentRoot의 각 디렉토리에 .htaccess 파일이 있는지 확인하고 거기에 설정을 적용한 후 다음 디렉토리와 거기에 있는 .htaccess 파일로 내려갑니다.
예를 들어 "모두 거부"로 설정되어 있으면 /scripts/test/hello-world.php에 액세스하려는 방문자가 "모두 허용"으로 설정되어 있음에도 ./www/.htaccess
불구하고 거부됩니다 ../www/scripts/test/.htaccess
따라서 인증을 요청하는 PHP 스크립트가 아닌 경우 .htaccess 파일에 대한 상위 수준 디렉터리를 확인하는 것이 좋습니다.