PHP and htaccess question
March 17, 2009 5:58 AM
Subscribe
I use .htaccess files to allow users access to files in certain directories based on their IP addresses/ranges. They are linked to these file from a page (not within the htaccess protected directory) generated in PHP. Is there a way to display a variable on this PHP page based on whether or not the user will be allowed access into .htaccess protected directories?
Ideally, if their IP address or range (CIDR) is in the htaccess file, they will be able to clink on the link and view the restricted files without any problems. If they don't have access, a link saying "Need to purchase this file?" will appear to the user.
Is this possible? I tried to google this but I am coming up short. Perhaps I am not using the best search criteria. Is there possibly a certain term for what I'm trying to do?
Are there any other similar solutions that would achieve the same result but I'm not aware of? A normal username/login system wouldn't work because some of the users come from institutions (Universities, libraries) where it is just much more easier to grant access via IP addresses.
posted by chillmost to computers & internet (7 comments total)
1 user marked this as a favorite
Instead, vave your htaccess files generated from a database, then check an ip against that database from php.
posted by devnull at 6:20 AM on March 17