Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

htaccess allow access to specific user

Tags:

.htaccess

I'm trying to limit the access to every file from a specific user through htaccess.
Is it 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)

like image 476
ValtNet Avatar asked May 16 '12 16:05

ValtNet


1 Answers

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

More information can be found at plenty of online references, this is one of the first that came up: http://www.apacheweek.com/features/userauth

like image 152
M Sost Avatar answered Oct 13 '22 22:10

M Sost