在/var/www/html创建一个secret目录,仅允许本地用户访问
1,访问需要密码
yum install httpd*
service httpd restart
tcp 80
chkconfig httpd on
mkdir /var/www/html/secret
vim /etc/httpd/conf/httpd.conf
<Directory /var/www/html/secret>
AllowOverRide AuthConfig
</Directory>
service httpd restart
vim /var/www/html/secret/.htaccess
AuthName "secret"
AuthType Basic
AuthUserFile /var/www/html/secret/.htpasswd
Require valid-user
htpasswd -c /var/www/html/secret/.htpasswd username
2,仅127.0.0.1访问
vim /etc/httpd/conf/httpd.conf
<Directory /var/www/html/secret>
AllowOverRide None
Order deny,allow
deny from all
allow from 127.0.0.1
</Directory>
service httpd restart
links