Dragen Posted April 28, 2007 Share Posted April 28, 2007 Hi, I was just wondering.. I've got a login script, but to use it I have to add a snippet of code to each page I want protected by the login. Is it possible to use php to protect a whole directory, without having to add the code to each file? I'm presuming I would somehow use the .htaccess file... Thanks Link to comment https://forums.phpfreaks.com/topic/49119-password-protect-a-whole-directory/ Share on other sites More sharing options...
per1os Posted April 28, 2007 Share Posted April 28, 2007 .htaccess with .htpasswd would work. If you wanted PHP to handle the authentication than use .htaccess with mod re-write to re-direct any call to that directory to a "process.php" file which can look at the DIR being called and than do a user check at which point if valid, it includes the requested file from the directory. Link to comment https://forums.phpfreaks.com/topic/49119-password-protect-a-whole-directory/#findComment-240676 Share on other sites More sharing options...
Dragen Posted April 28, 2007 Author Share Posted April 28, 2007 thanks. To be honest I've never used htpasswd before.. I've just googled some stuff and found this quote: In the htpasswd file, you place the username and password (which is encrypted).... the htpasswd file would look like this: wsabstract:y4E7Ep8e7EYV What type of encryption is it?? It doesn't explain anywhere about the type of encryption.. I would've presumed md5, but I'm sure md5 is 32 characters long... Link to comment https://forums.phpfreaks.com/topic/49119-password-protect-a-whole-directory/#findComment-240686 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.