日期:2014-05-17  浏览次数:20719 次

在apache中配合htacess文件给目录加密

我在网上找了好久,关于如何配置apache给网站目录加密,好难找到哦。这里记录一下自己配置的心得。与大家分享。我在windows下配置的。大家在linux下配置的话,稍微改一下也可以用,并没有系统的区别。

?

apache/conf/httpd.conf
下面中
Alias /site/ "E:/website/"
<Directory "E:/website/">
??? Options Indexes MultiViews
??? AllowOverride All
??? Order allow,deny
??? Allow from all
</Directory>

AllowOverride None 改为?? AllowOverride All

?

编写.htacess文件

Deny from all
AuthType Basic
AuthUserFile .htpasswd
AuthName "abc"
require abc
satisfy any


编写.htpasswd密码文件

C:\xampp\apache\bin>htpasswd.exe -c E:\website\secret\images\.htpasswd abc
Automatically using MD5 format.
New password: *******
Re-type new password: *******
Adding password for user abc

将.htacess文件和.htpasswd密码文件保存到E:\website\secret\images\目录下
重启Apache即可

?

再输入http://localhost/site/secret 后就会弹出要用户名和输入密码的窗口。