To password protect your whole website or a particular folder, you'll need to upload two files (.htpasswd and .htaccess) to your website. To generate these two files, you'll need to have the following things ready first.
Things you'll need
- a FTP program, such as FileZilla
- your FTP user name and password (you can find them on the My Services Overview page in your Toolkit)
- your website's full directory path (this can be found on the My Services Overview page as well)
Generating .htpasswd and .htaccess
The dot at the beginning of .htaccess and .htpasswd signify that they are hidden files on the Linux server. To handle these files properly, we recommend you follow the following steps carefully.
Firstly, enter the user name and password (the login credentials that you want to use to password protect your website) in the following fields, and then click Submit.
| User name: | |
| Password: | |
Once you've clicked the Submit button, the content of the .htpasswd and .htaccess file will appear in the text areas below. Follow the steps to save and upload the files to your website.
.htpasswd
- Copy the codes in the following text area and paste them into a text editor (such as Notepad).
- Save the file as htpasswd.txt
- Use your FTP program to connect to your web space.
- Upload the htpasswd.txt file to the top-level directory of your web space (the top-level directory is where your public and cgi-bin folders are stored).
- Rename the htpasswd.txt to .htpasswd
.htaccess
- Copy the codes in the following text area and paste them into a text editor (such as Notepad).
- Replace /path/to/ on the first line with your website's full directory path.
- Save the file as htaccess.txt.
- Use your FTP program to connect to your web space.
- Upload the htaccess.txt file to the folder where you want to password protect.
For example, if you want to password protect your website homepage, then upload the file to the /public/www folder; if you want to protect a subfolder (such as www.your_website.com/documents), then upload the file to /public/www/documents. - Rename htaccess.txt to .htaccess
Once you've uploaded and renamed the files, the password protection will take effect instantly. For more information about website access control, see Authentication, Authorization and Access Control.
