Article Diary - General Knowledge Digest

How to password protect folder/files using htaccess file?

Use the following htaccess code to enable authentication for certain files and folders from being accessed. The code has examples of password protection for a single file and password protection for a entire directory using htaccess file.

# to protect a file

AuthType Basic
AuthName “Prompt”
AuthUserFile /home/path/.htpasswd
Require valid-user

# password-protect a directory

AuthType basic
AuthName “This directory is protected”
AuthUserFile /home/path/.htpasswd
AuthGroupFile /dev/null
Require valid-user
Attached Files
There are no attachments for this article.
There are no comments for this article. Be the first to post a comment.
Security Code Security Code
Related Articles RSS Feed
SEO (Search Engine Optimization) vs SEM(Search Engine Marketing)
Viewed 838 times since Mon, Jul 12, 2010
How to restrict access to your .htaccess file?
Viewed 981 times since Sun, Mar 14, 2010
Before and After Picture - jQuery Plugin
Viewed 1329 times since Tue, Dec 29, 2009
Google Maps jQuery Plugin - gMap
Viewed 1336 times since Mon, Feb 8, 2010
Free Android GUI PSD File
Viewed 1312 times since Fri, Dec 4, 2009
30 High Quality Charts & Graphs for Web Developers
Viewed 2832 times since Wed, Mar 23, 2011
PHP Sound Captcha
Viewed 9055 times since Sun, Apr 11, 2010
Viewed 959 times since Sun, Jan 17, 2010