使用.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
然後在訪問目錄測試