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
5 (1)
Article Rating (1 Votes)
Rate this article
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
Flash Webcam Image Capture
Viewed 1634 times since Thu, Nov 12, 2009
Modify HTTP Headers in PHP with Examples
Viewed 1152 times since Wed, Mar 10, 2010
Create Navigation Menu Easily with jQuery Menu
Viewed 1204 times since Thu, Dec 31, 2009
Inline Form Validation With jQuery
Viewed 1427 times since Sat, Jan 9, 2010
Free Under Construction Coming Soon Template
Viewed 1998 times since Sat, Mar 12, 2011
Google Web Toolkit - Version 2 Released
Viewed 1106 times since Tue, Dec 15, 2009
30 High Quality Charts & Graphs for Web Developers
Viewed 3030 times since Wed, Mar 23, 2011