如何不让别人访问网站目录

apache服务,经常进入一个目录,会列出所有的文件,这样对安全很不好。

如何禁止别人访问到附件所示的目录结构ne?

原先我以为直接用FTP修改目录权限就可以,后来搜索发现不是这样,正确的解决方式是这样:

找到apache服务目录下的httpd.conf 文件

找到:
#
# 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 Includes ExecCGI

#
# 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 All

#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all
Options -Indexes

加粗部分就是我添加的代码。添加了这段代码之后重新启动apache服务器

重启后再访问那个目录会出现403错误!,问题就解决了。

如图: