I would like to rewrite all requests for http://models.example.com/*
to http://models.example.com/handler.php?requested_url=*
Then, handler.php
would check my $_SESSION
variables to see if the user is logged in. If the user is logged in, then handler.php
would redirect to the requested_url
.
If the user is not logged in, then handler.php
would use regular expressions to find matches between requested_url
and an array of permission rules (ruleList.php
). If handler.php
sees that there is a rule allowing non-logged-in users to access requested_url
then it would redirect to the requested_url
, otherwise it would redirect to a login page.
My problem is this: How do I distinguish between an initial request and a redirection? (to avoid an infinite loop). I can append a variable like &already_processed=true
, but that is completely insecure.
I would use mod_auth, but the problem is that I want the permissions to be settable through the website's administrative panel (ruleList.php
). The permission rules could be complex, and the people setting them should not have to poke around in the server's httpd.conf file. Another problem with mod_auth is that changes would require the server to be reset.
I'd appreciate any input on the subject!