php禁止列目录的实现方法:首先找到并打开“httpd.conf”文件;然后在“options indexes followsymlinks”的“indexes”前面加上“–”符号;最后保存修改即可。
推荐:《php视频教程》
apache中禁止显示目录文件列表的配置方法
假如你输入一个虚拟目录的地址:http://localhost:8080/b/
如果该虚拟目录下没有 index.html,浏览器也会显示该虚拟目录的目录结构,列出该虚拟目录下的文件和子目录。
如何禁止 apache 显示目录列表呢?
要禁止 apache 显示目录结构列表,只需将 option 中的 indexes 去掉即可。
比如我们看看一个目录的目录配置:
<directory "d:/apa/blabla"> options indexes followsymlinks #----------> options followsymlinks allowoverride none order allow,deny allow from all</directory>你只需要将上面红色代码中的 indexes 去掉,就可以禁止 apache 显示该目录结构。用户就不会看到该目录下的文件和子目录列表了。
indexes 的作用就是当该目录下没有 index.html 文件时,就显示目录结构,去掉 indexes,apache 就不会显示该目录的列表了。
如果这样设置可能还是会显示目录列表:
<directory / > options followsymlinks allowoverride none order allow,deny allow from all</directory>第二种方法
编辑httpd.conf文件编辑httpd.conf文件
vi ./conf/httpd.conf找到如下内容:
……<directory “c:/program files/apache2.2/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.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>……在options indexes followsymlinks在indexes前面加上 – 符号。
即: options -indexes followsymlinks
【备注:在indexes前,加 代表允许目录浏览;加 – 代表禁止目录浏览。】
这样的话就属于整个apache禁止目录浏览了。
如果是在虚拟主机中,只要增加如下信息就行:
<directory “d:\\\\test”> options -indexes followsymlinks allowoverride none order deny,allow allow from all</directory>这样的话就禁止在test工程下进行目录浏览。
备注: 切记莫把“allow from all”改成 “deny from all”,否则,整个网站都不能被打开。
还有一种方法:
可以在根目录的 .htaccess 文件中输入
<files *>options -indexes</files>就可以阻止apache 将目录结构列表出来。
有哪些邮件群发软件推荐COVID如何取消电脑IE浏览器中允许对剪切板进行访问的提示鞍山如何注册商标网址注册可以在哪个平台注册?上海备案填写了验证码怎么提示还是提示没有网站负责人的照片农产品发现新机遇?网站建设助力转型云服务器配置1核够