htaccess的密码保护,不同的用户文件 [英] htaccess password protect files with different users

查看:213
本文介绍了htaccess的密码保护,不同的用户文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文件服务器,我用mod_autoindex到服务器中的文件。我在htaccess的用户名和密码,以便只有特定的人可以访问这些文件。我已经加入其他用户HTPASSWD但我只喜欢那个用户访问某些文件/文件夹。

I have a files server and I use mod_autoindex to server the files. I have a username and password in htaccess so only certain people can access the files. I have added another user to htpasswd but I would only like that user to access some of the files/folders.

下面是我的htaccess的文件现在:

Here is my htaccess file now:

AuthType Basic
AuthName "restricted"
AuthUserFile E:\\path\\to\\.htpasswd

<Files "filesForAnyUser\\*">
  Require valid-user
</Files>

<Files "*">
Require user admin
</Files>

我敢肯定,我做错了什么,但我无法找到任何这很好的文档。

I'm sure I am doing something wrong but I can't find any good documentation on this.

推荐答案

如果您有一个名为filesForAnyUser文件夹,在那里你只对管理有文件的文件夹,你需要做2 htaccess的文件。其中在filesForAnyUser:

If you have a folder called "filesForAnyUser" and a folder where you have files only for admin, you need to make 2 htaccess files. One in "filesForAnyUser":

AuthType Basic
AuthName "restricted"
AuthUserFile E:\\path\\to\\.htpasswd
Require valid-user

和一个在其他目录下:

AuthType Basic
AuthName "restricted"
AuthUserFile E:\\path\\to\\.htpasswd
Require user admin

这篇关于htaccess的密码保护,不同的用户文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆