apache控制是否显示站点目录

6 篇文章 0 订阅

加载 mod_autoindex 模块

apache 2.4版本,如果要控制站点目录是否显示,需要 mod_autoindex 模块。如果没有该模块,显示站点目录的指令无效。

加载该模块

LoadModule autoindex_module modules/mod_autoindex.so

方法一

解决过程:首先查看apache官网文档,不能快速找到需要的部分。用搜索引擎查找“apache显示站点目录”,找到相关资料,雷同。按照资料说明配置无效。
开始尝试在虚拟主机和非虚拟主机尝试资料中的配置,仍然无效。再回到官网文档查找关键词“Options Indexes”,看到“mod_autoindex can generate a listing of the directory contents”,
然后全文检索httpd.conf,意识到是因为相关模块没有加载。

虚拟主机显示站点目录

apache 2.4版本默认不显示站点目录,虚拟主机配置如下:

<VirtualHost *:80>
    ServerAdmin chuganghong@qq.com
    DocumentRoot "E:\wamp64\www\my-site\test-php"
    ServerName test-php.com
    ErrorLog "logs/test-php.com-error.log"
    CustomLog "logs/test-php.com-access.log" common
</VirtualHost>

加入显示站点目录的指令 Options +Indexes,完整代码如下:

<VirtualHost *:80>
    <Directory "E:\wamp64\www\my-site\test-php">
        Options +Indexes    # 显示站点目录
    </Directory>
    ServerAdmin chuganghong@qq.com
    DocumentRoot "E:\wamp64\www\my-site\test-php"

    ServerName test-php.com
    ErrorLog "logs/test-php.com-error.log"
    CustomLog "logs/test-php.com-access.log" common
</VirtualHost>

Options +IndexesOptions Indexes 或没有这条指令,显示站点目录。
Options -Indexes,禁止显示站点目录。

参考资料

mod_autoindex can generate a listing of the directory contents

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值