.htaccess 目录_使用.htaccess密码保护目录

.htaccess 目录

Protecting files on your website from unauthorized users can be very important. Even more important is the method by which you accomplish this task. You could use PHP to listen for login authorization information on each page, but that doesn't protect your images, documents, and other media, does it? That's why I've found the .htaccess method of protecting files and directories the most reliable. Oh, and it's easy too!

保护您网站上的文件免受未经授权的用户的侵害非常重要。 更为重要的是完成此任务的方法。 您可以使用PHP侦听每个页面上的登录授权信息,但这不能保护您的图像,文档和其他媒体,对吗? 这就是为什么我发现保护文件和目录的.htaccess方法最可靠的原因。 哦,这也很容易!

The system requires two files -- the .htaccess file and .htpasswd file.

系统需要两个文件.htaccess文件和.htpasswd file

.htaccess代码 (The .htaccess Code)

AuthType Basic
AuthName "restricted area"
AuthUserFile /home/davidwalsh/html/protect-me-dir/.htpasswd
require valid-user

The above code protects a directory called "protect-me-dir" at root level. The "AuthUserFile" value is always specific to your hosting configuration. If you don't know what the value should be, do a phpinfo() and find the DOCUMENT_ROOT value.

上面的代码在根级别保护一个名为“ protect-me-dir”的目录。 “ AuthUserFile”值始终特定于您的托管配置。 如果您不知道该值是什么,请执行phpinfo()并找到DOCUMENT_ROOT值。

.htpasswd代码 (The .htpasswd Code)

davidwalsh:daWHfZrDLB88.
rodstewart:roFulYxC2.8ws
cssexpert:csmnmq.M8T5ho

The .htpasswd file contains the usernames and passwords of allowed users. One per line. The passwords are MD5'd for security purposes.

.htpasswd文件包含允许用户的用户名和密码。 每行一个。 为了安全起见,密码是MD5密码。

To generate encrypted passwords for your .htpasswd file, you can use my .htaccess password generator.

要为您的.htpasswd文件生成加密密码,可以使用.htaccess密码生成器

翻译自: https://davidwalsh.name/password-protect-directory-using-htaccess

.htaccess 目录

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值