htaccess的允许访问特定用户用户、htaccess

2023-09-02 09:51:29 作者:懦弱给谁看゛

我试图限制从一个特定的用户通过htaccess的访问到每个文件。 它甚至可能吗? 我无法弄清楚如何让每一个文件的访问只有当用户名不是具体的某一种,我使用HTTP登录用PHP(的$ _ SERVER REMOTE_USER)

I'm trying to limit the access to every file from a specific user through htaccess. It's even possible? I can't figure out how to allow every file access only if username is not a specific one, I use an HTTP login with PHP (REMOTE_USER of $_SERVER)

谢谢,对不起我的英文不好:)

Thanks and sorry for my bad english :)

推荐答案

您需要创建一个要允许与htpasswd的工具用户数据库/特定用户。从那里,在目录中的htaccess文件要限制,使用方法:

You'll need to create a user database/specific user you want to allow with the htpasswd utility. From there, in your htaccess file in the directory you want to limit, use:

AuthUserFile /path/to/.htpasswd
AuthName "Authorization Form Title"
AuthType Basic

#Allow any valid user
require valid-user

#Allow only one user with specified username
require user username

更多信息可在网上大量的引用中找到,这是第一次那上前之一: HTTP ://www.apacheweek.com/features/userauth