PHP create password protected folders

4k Views Asked by At

I would like to know if there is a way in PHP to create a password protected folder on the fly.

I need to create a specific folder INSIDE a main folder and password protect the new folder with a password chosen by the user.

Is there a way in PHP to achieve something like this?

Thank you!

Oh and also this folder should not be accessible from the web, and no one, EVEN the server administrator should be able to open it without the password.

I know it sounds like crazy, but this is for a copyright service, a serious thing.

LEt me know

1

There are 1 best solutions below

0
On BEST ANSWER

This can be done for example by .htaccess placed in the folder you want to protect. Check this: http://www.elated.com/articles/password-protecting-your-pages-with-htaccess/.

Another way could looke somehow like this:

  1. In the protected folder create .htaccess file with this content: deny from all - this will deny access for everyone except server itself.
  2. Create a password protected script (password can be given as a GET variable) that will send to the client the requested file from protected folder if entered password is correct. (+ there can be used ReqriteRules in .htaccess (placed in root folder) to make links to the protected files nicer)