views:

17

answers:

1

I need to protect a site that has a ton of static .html files. The standard .htaccess scheme doesn't meet the requirements.

Is there a way to specify an .htaccess style of password protection with a custom handler? That is I need to write the code to determine if the user is allowed or not, but I don't want to modify a million .html files all over the place.

Thanks!

+2  A: 

Maybe. It depends on what modules are loaded on your web server. Your options will range from keeping a simple list of users in a flat file, to keeping them in a database and customizing the queries.

http://httpd.apache.org/docs/2.2/howto/auth.html

Another option - just brainstorming here - is to use something like mod_rewrite to redirect the calls to the physical file to something like a PHP script that can manage the user/password authentication for your, and if authenticated, go out and load the html file that was requested. So calls to www.some.com/10203.html actually get directed to www.some.com/auth.php?10203.html, which would control access to that underlying html file. That would of course require mod_rewrite to be installed, which is pretty common even for shared hosting environments.

GrandmasterB
@GrandmasterB - I love the mod_rewrite idea. that is exactly what I am going to do thanks!
Byron Whitlock
Glad I could help!
GrandmasterB