Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

is it possible to read the username/password of .htaccess from a database (to allow multiple users) i need to manage it using apache and database only without having any PHP/perl code level any idea is highly appreciated. Regards

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted
echo "
AuthName "SECURE AREA"
AuthType Basic
AuthGroupFile /dev/null
AuthMySQLHost DB_HOST
AuthMySQLDB DB_NAME
AuthMySQLUserTable TABLE_NAME
require valid-user
AuthMySQLUser DB_USER
AuthMySQLPassword DB_PASSWORD
AuthMySQLNameField USERFIELD_IN_TABLE
AuthMySQLPasswordField PASSWORDFIELD_IN_TABLE
AuthMySQLMD5Passwords On " >> .htaccess
share|improve this answer
1  
Requires mod_auth_mysql, but is a well working solution. +1 –  pehrs Oct 28 '10 at 13:10
add comment

As far as I know it is not possible. You could write a script (in an available language) which creates the .htaccess for you.

Querying the database from within a .htaccess is not possible. You could write a mod though ;)

EDIT: I didn't know that there is a mod already :) Sorry.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.