Apache身份验证
访问控制 (基于用户)
<Directory "/ee">
Options Indexes MultiViews
AllowOverride None
Authname "your name"
Authtype basic
Authuserfile /etc/httpd/passwd
Require user tom mike
Order allow,deny
Allow from all
</Directory>
htpasswd -c /etc/httpd/passwd tom 建用户
chmod 644 /etc/httpd/passwd
htpasswd -m /etc/httpd/passwd tom 改密码
v 基于组的验证 (在用户的配置文件的基础上)
v <Directory "/ee">
v Options Indexes MultiViews
v AllowOverride None
v Authname "your name"
v Authtype basic
v Authuserfile /etc/httpd/passwd
v Authgroupfile /etc/httpd/gw
v Require group www
v Order allow,deny
v Allow from all
v </Directory>
v # vi /etc/httpd/gw
§ www: tom mike
v 基于每个目录下的.htaccess
v Alias /aa "/aa/"
v <Directory "/aa">
§ Options Indexes MultiViews
§ AllowOverride AuthConfig
§ Order allow,deny
§ Allow from all
v </Directory>
v [root@localhost ~]# vi /aa/.htaccess
§ Authname "your name"
§ Authtype basic
§ Authuserfile /aa/.passwd
§ Require valid-user
v htpasswd -c /aa/.passwd aa
v chmod 644 /aa/.passwd
测试结果:
转载于:https://blog.51cto.com/sngyqd/395002