apache利用.htaccess控制客户端访问

来源:岁月联盟 编辑:exp 时间:2011-09-29

使用.htaccess文件来控制使用者的存取
#vim /etc/httpd/conf/httpd.conf
<Directory "/var/www/html/tips">
             AllowOverride authconfig
</Directory>
#mkdir /var/www/html/tips
#cd /var/www/html/tips
#vim .htaccess
AuthName "htaccess"
AuthType "basic"
AuthUserFile /var/www/html/tips/wwwpasswd  //使用wwwpasswd验证使用者的档案
require  valid-user
#htpasswd -c wwwpasswd george  //建立george使用的档案wwwpasswd的密码
new password:
-c只在第一次才使用
#htpasswd wwwpasswd xiaozhu
然后在访问目录测试


作者“新网络人为本”