Multidirectory htaccess management

I’m wondering if anyone can point me in the right direction, I can’t believe someone hasn’t written something like this already.

I’m open on the interface but I would envision a php/mysql interface for maintaining users/passwords and (multiple paths) that generates htaccess files for them.

I imagine people do this all the time but I want to start making our journal publication available online.
I have the flip page style online magazine working but I need to make access control for the members for individual quarters/years.
I think I’ll just drop them all in different directories and maintain a .htaccess file.

Thanks, ideas, criticisms (maybe this is stupid) welcome :wink:


Sorry, I’m not quite sure what you’re asking. Are you creating new directories for each user/password combination and trying to auto-generate an .htaccess file for each? Timeout on each directory, too?

.htaccess files are heirarchical, i.e., the DocumentRoot’s .htaccess directives will apply to all subdirectories unless further directives are within those directories’ .htaccess files. This does not sound like it would help with what you’ve (almost) described.

When creating a new username/password, you seem to need a new directory with its own .htaccess file. If your new directory is created automatically, that same script can also create an .htaccess file for that directory. The only thing missing at that point would be the 'nix password file for that directory (see how ugly this is getting?).

IMHO, this is getting overly and unnecessarily complex.

Thinking outside the box you almost described, I would build an access page to query your database (for username, password and expiration date) and provide the data from OUTSIDE your webspace (meaning from a directory at the same level as your public_html directory) via PHP.



No not a directory for each user, a directory for each quarterly publication for many years,
I want a system that I can say which quarterly publications a user can have access to.
Joe has access to 1st quarter 2007, 2nd and 3rd quarter of 2008, and all 4 quarters of 2009.
Bob has access to 3rd and 4th quarter of 2008, and 1st quarter of 2009.
My thought is every quarter is a directory (I drop the magazine in) and the database builds the htaccess file and drops it in the directory for appropriate quarter for all users that have access there.


Again, that sounds more like a database decision maker than going to the extreme of making (potentially) hundreds of password protected directories. The only difference to what I’d recommended in my first post is that you might have to add a start date (if you don’t want to have a member view older archives).

Do it the hard way if you want but I’d just recommend that you think out of the box you’ve enclosed yourself in.



Yes it is a database decision maker I was just hoping one was out there so I didn’t have to write it, since this doesn’t sound all that crazy or uncommon.

The software that wraps the books to make this work I suspect I could wrap with a php and do sessions but I’d really like to keep my fingers out of the “published” distribution, i.e. you click publish and they give you a tree you drop on your web.

I started writing it last night another hour or two and I’ll have it complete.