I am trying to modernize an older website that has three sections corresponding to three different sets of users: a public section for everybody, a members section for logged-in users, and an admin section for administrators. I'm running into trouble using one login script for both the members and the admins.
My directory structure currently looks like this:
/mysite <- for everyone
/mysite/member
/mysite/admin
/mysite/common/login
For login, I've installed the HUGE user authentication script by Panique (https://github.com/panique/huge). HUGE sets configuration variables using a file named config.{environment variable}.php.
The database has two different user tables-- one "members" table with user information, one "admins" table for administrators . I'd like to keep this table structure because I don't want to edit hundreds of files to reflect the change.
If I edit .htaccess in /mysite, I can set the environment variable, then redirect hits on /mysite/member to go to /mysite/common/login as follows (I use 302 because I'm still messing around):
SetEnv APPLICATION_ENV admin
RewriteRule ^admin common/login/public [R=302,NC,L]
It works okay so far. It sets the environment variable, jumps to /mysite/common/login/public, then HUGE loads config.admin.php. Then I can set the users table and path variables in config.admin.php. I'm able to log in although haven't gotten as far as to access the files in admin.
Right now, I can't figure out how to set the environment variable for both admin and members. Among other things, I tried creating the following .htaccess files but they didn't work. In /mysite/admin:
SetEnv APPLICATION_ENV admin
RewriteEngine On
RewriteRule * common/login/public [R=302,NC,L]
In /mysite/member:
SetEnv APPLICATION_ENV member
RewriteEngine On
RewriteRule * common/login/public [R=302,NC,L]
I know that my RewriteRule syntax is wrong at the least, but it may also be wrong to do these redirects at all. Will I be able to access files in admin and member once logged in, or will they keep rewriting to common/login/public?
P.S. I am open to alternatives to get the job done in a simpler way. The fast and dirty way to get the job done would be to just duplicate the login script so each section has its own copy. But I'd like to avoid this.