apache配置和.htaccess文件相关

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文件失效不再起作用了 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值