当前位置: 移动技术网 > 网络运营>服务器>Linux > Apache控制是否显示站点目录(推荐)

Apache控制是否显示站点目录(推荐)

2019年04月27日  | 移动技术网网络运营  | 我要评论

加载 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 +indexes 或 options indexes 或没有这条指令,显示站点目录。

options -indexes,禁止显示站点目录。

以上所述是小编给大家介绍的apache控制是否显示站点目录,希望对大家有所帮助

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网