Surprised I haven’t written this up before now. It is very simple to do.
This assumes you are using apache on a unix based system. This should work on any OS running apache though.
- In the directory you want to restrict create a file named .htaccess that contains the following:
AuthType Basic AuthName "RESTRICTED ACCESS" AuthUserFile /home3/speedtow/.htpasswd Require valid-user
- Note: AuthName can be anything you want it to say and AuthUserFile must be an absolute path to the .htpasswd file. It can be anywhere, I wouldn’t recommend putting it in the directory you are restricting though, or any apache served directory for that matter.
- Create the .htpasswd file by running htpasswd in the location you want it to live. It will go something like this:
$ htpasswd -c .htpasswd username New password: Re-type new password: Adding password for user username
Thats it, your done.