apache的配置文件 httpd.conf
<Directory "D:/xampp/htdocs">
#
# 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.4/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks Includes ExecCGI
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# AllowOverride FileInfo AuthConfig Limit
#
# AllowOverride All
AllowOverride None
#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>
配置项 AllowOverride 设置为None后, 那么项目中的.htaccess文件中的指令将失效,即不在起作用; 反之 设置为 All 时, .htaccess文件将会生效
如.htaccess文件如下:
<IfModule authz_core_module>
Require all denied
</IfModule>
<IfModule !authz_core_module>
Deny from all
</IfModule>
操作如下:
(1) 将AllowOverride 设置为All
<Directory "D:/xampp/htdocs">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
(2) 重启apache, 访问codeigniter框架下的application目录:http://localhost/ci/application/
可以发现,禁止访问 !!!!
(3) 重新配置httpd.conf如下:
<Directory "D:/xampp/htdocs">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride None
Require all granted
</Directory>
重启apache后再次访问 application目录: http://localhost/ci/application/
可以发现, AllowOverride改为None后,就可以访问到index.html中的内容了, 即 .htaccess文件失效不再起作用了