Hi guys,
I have a script that, when you enter the directory the .htaccess file is it, it makes you authenticate. When you authenticate correctly, it redirects you to your subdirectory. For example, if I successfully logged in as 'Physicsguy', it would redirect me to 'physicsguy/'. The problem is, though, is not allowing the URL to be changed and allow Physicsguy into admin/.
Here is my script:
.htaccess:
Code:
AuthType Basic
AuthName "Restricted Area"
AuthUserFile (path to .htpasswd)/.htpasswd
Require valid-user
Example .htpasswd file:
Code:
person1:.mawDZ5WDShOM
person2:PNFL7nw0WksGU
person3:7ju7Ox/UWYoRI
*The passwords are pass1, pass2, and pass3*
PHP file inside the directory that the user sees when they authenticate successfully:
PHP Code:
<?php //$_SERVER['PHP_AUTH_USER'] = Entered username //$_SERVER['PHP_AUTH_PW'] = Entered password if (!isset($_SERVER['PHP_AUTH_USER'])){ header('WWW-Authenticate: Basic realm="My Realm"'); header('HTTP/1.0 401 Unauthorized'); exit; } else { header("Location: ".strtolower($_SERVER['PHP_AUTH_USER'])."/"); } ?>
So how can I get it to ask you to reauthenticate if you try to access somebody else's directory? Of course, I'd like an easy solution, rather than have custom .htaccess and .htpasswd files for EACH directory (I have a lot).
Thanks!
-PG
Last edited by Physicsguy; 09-10-2011 at 01:35 PM..
|