Redalto Communications Support Site
Question: How can I Password Protect a Directory?
This question relates to the following categories: Business Hosting, Web Hosting
Answer:
To password protect a folder on your website, you simply create 2 files:
1. .htaccess : this is a file that will reside within the directory/folder you are wanting to password protect
2. .htpasswd : this is a file that will reside within your hosting account root directory
The following provides an overview on how to create these files and password protecting your web directories.
1. Creating the .htaccess file
Using Notepad or other text editor, create a new text file called '.htaccess' and include the following code:
AuthUserFile /home/example/account
AuthName "Restricted Area"
AuthType Basic
Require valid-user
* Note: replace "/home/example/account" with the real file path name of your hosting account. This was sent to you with your hosting welcome letter.
2. Creating the .htpasswd file
Again, using Notepad or text editor, create a text file called '.htpasswd'. Using the htpasswd generator, create the required username and password code that you want to use to communicate to your audience. The code will look something like this -> username:OOUmQBYo. Once you've done this, copy and paste into the text file, save and close it.
*Note if you want more than one username and password, simply repeat the previous step and paste each username code on a new line within the .htpasswd file. For example:
user1:OouOQBYv
user2:7DNQ6yvU
3. Copy your files to your hosting account
Using an FTP client, upload the .htaccess and .htpasswd files to their required diretories within your hosting account
.htaccess : this file will reside within the www/directory/folder you are wanting to password protect
.htpasswd: this file will reside within your hosting account root directory (above your website root folder for security reasons)
4. Test your password protection
To ensure it's all working, using your web browser, type in the full web address (including the name of the file you want to link to) of the location you've password protected. If you've setup everything correctly, you'll now be prompted for a username and password.
If you experience any difficulties, please email us the full details of your hosting account and the directory you're trying to password protect and we'll be happy to take a look at it for you. (Please note:: you're reading a Web Hosting company's support site, only contact our technical support if you're a Redalto Web Hosting customer)
Related Information:
- What is FTP?
- Do you recommend an FTP client?
- How do I upload my website to my hosting account?
- Uploading files via FTP using FileZilla
Actions: Print this, Email
- Author: Redalto Support Team
- Created on: 13 Nov 2007
- Views: 1310
- Last modified: 14 Jun 2010
Can’t Find the Answer You’re Looking For?
If you’ve searched our FAQ database and still can’t find the answer, please submit your question using the below form. We will contact you as soon as possible, and if necessary update the FAQ with the missing information.