5、防止用户访问指定的文件
系统中有一些文件是不适宜提供给WWW用户的,如:.htaccess、htpasswd、*.pl等,可以用<Files>;达到这个目的:
<Files .htaccess>;
order allow,deny
deny from all
</Files>;
用户访问控制三个.htaccess文件、.htpasswd和.htgroup(用于用户授权) ,为了安全起见,应该防止用户浏览其中内容,可以在httpd.conf中加入以下内容阻止用户对其进行访问:
<Files ~”/.ht”>;
Order deny, allow
Deny from all
</Files>;
这样这三个文件就不会被用户访问了。
<Location /prices/internal.html>;
order deny,allow
deny from all
allow from .domain.com
</Location>;
如果你要授于相应权限的机器没有公开的域名,请在你的/etc/hosts文件中,将其IP地址映射到某个指定的名称,然后在Location中对其进行设置,否则该选项是不起作用的。
#
# The following lines prevent .htaccess files from being viewed by
# Web clients. Since .htaccess files often contain authorization
# information, access is disallowed for security reasons. Comment
# these lines out if you want Web visitors to see the contents of
# .htaccess files. If you change the AccessFileName directive above,
# be sure to make the corresponding changes here.
#
# Also, folks tend to use names such as .htpasswd for password
# files, so this will protect those as well.
#
<Files ~ "^\.ht">;
Order allow,deny
Deny from all
Satisfy All
</Files>;