My
Ideal
Host
We do more than just host websites
Customer login
HOME
WEB
HOSTING
RESELLER HOSTING
CUSTOMER SUPPORT
TUTORIALS
COMPANY
View source
for
How to password protect a single file
<div align=-justify>To password protect a single file, make sure you have the following files under your account: * ''.htpasswd'' (containing the username and password to access the file) * ''.htaccess'' (containing the authentication rules) In case these files aren't listed under your account, you can create them via your cPanel => File Manager or via any FTP client. You should follow these steps: 1) Make sure to create .htpasswd file above your public_html directory. Otherwise it will be accessible through http requests. It is strongly recommended to use the root folder at /home/username/ (where '''username''' is your actual cPanel username). This file should contain the encrypted password for your username. You can create it using the following username/password generator: http://www.htaccesstools.com/htpasswd-generator/ 2) Put the .htaccess file in the directory of the file that you wish to be protected. '''''Note:''''' as .htaccess files work recursively, those changes will affect all subfolders in the directory the .htaccess file is placed in. Once the .htaccess file is created, add following lines to it: <FilesMatch '''"file.html"'''> AuthName "Member Only" AuthType Basic AuthUserFile /home/'''username'''/.htpasswd require valid-user </FilesMatch> The ''<FilesMatch "file.html">'' line allows you to specify the criteria for protecting your files. There are two options here: * a single file <FilesMatch "file.html"> * or files with the same name but of different types: <FilesMatch "file.*"> In the ''AuthUserFile /home/username/.htpasswd'' line '''username''' should be changed to your actual cPanel username. </div>
Return to
How to password protect a single file
.
Navigation
Hosting Issues
Cloud Hosting
Billing Issues
FAQ
Articles
News
Interesting from the web
Search
Subscribe to our newsletters