troubleshooting Question

POST .htpasswd using php variables!

Avatar of j79
j79 asked on
11 Comments1 Solution503 ViewsLast Modified:


I have a database where users can login with php/mysql and what I want to do now is to create a protected directory on an extern server with .htaccess/.htpasswd but I don't want to create now every user again and put them into the .htpasswd file.
Is it possible to realize this intention using a php page with redirection to this domain/directory in which a "global" user/password is set as variable and automatically has access to the protected directory?

I tried it with:
$PHP_AUTH_USER = "myuser";
$PHP_AUTH_PW = "mypassword";
$_SERVER['PHP_AUTH_USER'] = "myuser";
$_SERVER['PHP_AUTH_USER'] = ",mypassword";

but without any success, after redirection the HTTP-AUTH window is poping up askind the username/password.

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 11 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 11 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros