How to password protect your webpages using .htaccess
Password protecting a members folder is the most popular use of a .htaccess file. This page will provide you with easy step-by-step instructions on creating and uploading the protection. If you would like detailed information on the use of .htaccess to make the most of this technology, please click here.
If you do not have time for learning or would like to delegate the management of the password protection to someone, who is not computer savvy, we have written a solution already:
Zeus Server
Step by step instructions for password protecting a folder on your website
1. Open up a notepad on your desktop or any other text editor (apart from Microsoft Word).
2. Copy the following into the new file:
3. Save the file in text format and call it something like "htaccess.txt". You will rename it later, so the name is not so important at this stage.
4. Login to your website using FTP software.
5. Upload this text file into the folder, which you wish to protect.
6. Once on the server, rightclick on the file which you have uploaded and rename it to ".htaccess". When you hit the Enter key, the file will most likely disappear from your view. This is normal, because the dot in front of the name makes it a hidden file. Depending on your FTP software you may or may not be able to view hidden files.
Now you must create a password file for your users.
7. Use a htpasswd creator program to encrypt the passwords you give to your users. There are lots of these on the internet. Click on this link and bookmark it if you want.
8. Using the web based program provided in Step 7, enter the usernames and passwords of your users.
9. Click "Submit". This will bring up a results page with text.
10. Copy and paste this text into a new text file. (NOTE: do NOT use MS Word, it must be a .txt file type)
11. Name this file something like "htpasswd.txt"
12. Login to your website using FTP software.
13. Upload this text file into the folder, which you wish to protect.
14. Once the file is uploaded and on the server, right click on it and rename it to ".htpasswd". When you hit the Enter key, the file will most likely disappear from your view. This is normal, because the dot in front of the name makes it a hidden file. Depending on your FTP software you may or may not be able to view hidden files.
Now all you need to do is go to this folder on your website using a web browser to test your result. A window prompting to enter your username and password should come up. Test all of the users you have created.
Windows IIS Server
Password protecting a directory on IIS
Password protect a directory
You will need two files - .htaccess and .htpasswd.
1. Create a .htaccess file in the directory you wish to protect with the following code. Note to replace the AuthUserFile value with your absolute path on the server
AuthUserFile "\\samba\clientweb\n\r\netregistry.com.au\www\.htpasswd"
<FilesMatch ".html$">
Require valid-user
</FilesMatch>
** ".html$" differs depending on file extension i.e .asp .htm etc..
2. Create a .htpasswd file in your document root as per instructions in our .htaccess support tutorial.
OR
Password protect an MSAccess Database
If using a MSAccess database in your website, you need to ensure that the MSAccess .mdb file is not downloadable by direct access to the file. Password protect the download of the .mdb file by creating a .htaccess file in the same directory as the location of your .mdb file with the following information. Note to replace the AuthUserFile value with your absolute path on the server:
AuthUserFile "\\samba\clientweb\n\r\netregistry.com.au\www\stats\.htpasswd"
<FilesMatch ".mdb$">
Require valid-user
</FilesMatch>
Now you must create a password file for your users.
3. Use a htpasswd creator program to encrypt the passwords you give to your users. There are lots of these on the internet. Click on this link and bookmark it if you want.
4. Using the web based program provided in Step 7, enter the usernames and passwords of your users.
5. Click "Submit". This will bring up a results page with text.
6. Copy and paste this text into a new text file. (NOTE: do NOT use MS Word, it must be a .txt file type)
7. Name this file something like "htpasswd.txt"
8. Login to your website using FTP software.
9. Upload this text file into the folder, which you wish to protect.
10. Once the file is uploaded and on the server, right click on it and rename it to ".htpasswd". When you hit the Enter key, the file will most likely disappear from your view. This is normal, because the dot in front of the name makes it a hidden file. Depending on your FTP software you may or may not be able to view hidden files.
|