Apache 通过 .htaccess 对目录加密


例如有/home/www/website/dir1 目录,需要对/dir1/加密访问,必须输入口令密码才能访问。

在这种情况下,要是/dir1/加密可以通过 .htaccess 和 .htpasswd 的设置来实现

在/home/www/website/dir1下建立.htaccess文件
vi /home/test1/a/.htaccess
文件内容如下
AuthName “===LOGIN===”   #随便填写
AuthType Basic
AuthUserFile /home/www/website/dir1/.htpasswd
Require valid-user username
保存退出

账号生成口令
htpasswd -c /home/test1/a/.htpasswd username 系统会要求输入两遍该用户的密码。

修改密码也是同样 htpasswd -c /home/test1/a/.htpasswd username

716 thoughts on “Apache 通过 .htaccess 对目录加密

  1. Kia Haskins

    Hi my family member! I wish to say that this post is awesome, nice written and come with almost all vital infos. I would like to look extra posts like this .

  2. Laverne Furkin

    The next time I learn a weblog, I hope that it doesnt disappoint me as much as this one. I mean, I do know it was my option to learn, however I really thought youd have one thing interesting to say. All I hear is a bunch of whining about something that you may repair when you werent too busy looking for attention.

  3. Ardith Miyanaga

    Heard about this website from my buddy. He pointed me here and informed me I’d discover what I need. He was right! I got all of the questions I had, answered. Did not even take lengthy to seek out it. Love the truth that you produced it so simple for individuals like me.

  4. Marcus Reshard

    This article is an appealing wealth of informative data that is interesting and well-written. I commend your hard work on this and thank you for this information. You’ve got what it takes to get attention.

  5. Sling TV

    Simply desire to say your article is as astounding. The clarity to your post
    is just nice and i can think you are knowledgeable on this
    subject. Fine together with your permission let me to grasp your RSS feed to keep up to date with drawing close
    post. Thanks a million and please carry on the gratifying work.

发表评论