bspacer1 bspacer2
webmail hosting forum clients about

Computer Co-op, CornerNET Internet Gateway, and PJR Solutions is owned by PJR Sales & Service. Quality products and online services since 1991. We can be your
Complete Computer Connection

Hosting @ $5.95

Domains @ $16.98
Home PagePortal HomeClient AreaAnnouncementsKnowledgebaseSupport TicketsDownloadsRegister

Knowledgebase
You are here: Portal Home > Knowledgebase > cPanel Related Issues > cPanel HOW-TOs > How to password protect a single file?

How to password protect a single file?

In order to password protect a single file, you need to have the following files under your account:

.htpasswd (containing the username and password through which the file can be accessed)

.htaccess (containing the authentication rules)

You can create both files through your cPanel > File Manager.

You should follow these steps:

1) Do NOT create the .htpasswd file below your public_html directory. Otherwise it will be accessible through http requests. We would advise you to use the root folder for your account - /home/username/ (where username is your cPanel username).

In this file you should put the encrypted password for your username. This can be done using the following username/password generator:

http://home.flash.net/cgi-bin/pw.pl

2) Put the .htaccess file in the directory of the file that you wish to be protected. Please note that .htaccess files work recursively therefore those changes will affect all the subfolders in the directory that you have placed the .htaccess file in. Once the .htaccess file is in place, the following lines should be added to it:

<FilesMatch "file.html">
AuthName "Member Only"
AuthType Basic
AuthUserFile /home/username/.htpasswd
require valid-user
</FilesMatch>


In the <FilesMatch "file.html"> part you specify the criteria for protecting your files. You can choose a single file:

<FilesMatch "file.html">

or files from different types but with the same name:

<FilesMatch "file.*">

In the AuthUserFile /home/username/.htpasswd part you should change username to your cPanel username.



Was this answer helpful?

Add to Favourites
Print this Article

Also Read
How can I create different types of web redirect with my cPanel? (Views: 9230)
How can I enable anonymous FTP access in cPanel? (Views: 10272)
How can I retrieve the raw Apache access logs for my site? (Views: 2079)
How can I check my quota and bandwidth limits/usage? (Views: 11912)
How can I password protect a directory with cPanel? (Views: 11148)

Powered by WHMCompleteSolution


Copyright © 1994-2021 PJR Sales and Service All Rights Reserved