views:

305

answers:

2

Currently I have a .htaccess file within the directory of the folder I want to restrict, with the appropriate group that has access to it.

What I want to do is have one htaccess for the entire site, and restrict groups to specific URL's.

So I want staff to have access to:

/staff/..

and Students to have access to:

/students/..

I would prefer restricting by URL in the htaccess file, so I do not have to do it in the virtual host conf file, and restart service each time.

A: 

With htaccess, AFAIK, you would need a new htaccess for each of those folders. You could just create users with the same un/pw for each of the folders for continued access, but they would need to log in more than once.

Since you have this tagged under php, I can give you a better php solution :) Simply prompt the user for un/pw and create a session to set loggedin = 1 and you're good to go. If you want to make this secure, you should do it via db and include some sort of md5 security code in the session as well.

Citizen
+1  A: 

so i am guessing that your picking up the group from LDAP .. so as ur using PHP .. i am guessing u would have a top level include file for db connections etc. So u can pick up their group from the LDAP,store in session and in the include .. check that REQUEST_URI always goes to their relevant folder e.g /$_SESSION[group]/ .. if not redirect them there.

Sabeen Malik
maybe worth looking at http://www.rudedog.org/auth_ldap/1.6/auth_ldap.html#reqgroup
Sabeen Malik