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
How to prevent access to a specific file on server using htaccess?
Viewed 1004 times since Sun, Mar 14, 2010
JavaScript Tree Menu Component - jsTree Menu
Viewed 1613 times since Sat, Jan 9, 2010
How to restrict access to your .htaccess file?
Viewed 964 times since Sun, Mar 14, 2010
imgAreaSelect - jQuery Plugin To Select Areas On Images
Viewed 1334 times since Thu, Dec 31, 2009
Tiny Flash MP3 Audio Player
Viewed 982 times since Wed, Jan 6, 2010
Free Visualization Components For Flex (AS3)
Viewed 867 times since Sun, Jan 3, 2010
How to change the file type using htaccess?
Viewed 964 times since Sun, Mar 14, 2010
Geo-location Mapping With Google Maps API & PHP
Viewed 1325 times since Mon, Apr 4, 2011