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

resides
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.
Comments
There are no comments for this article. Be the first to post a comment.
Name
Email
Security Code Security Code
Related Articles RSS Feed
Web Form Elements in PSD Format
Viewed 920 times since Sun, Dec 27, 2009
Free Visualization Components For Flex (AS3)
Viewed 798 times since Sun, Jan 3, 2010
ICEpdf - Open Source Java PDF Library
Viewed 1176 times since Wed, Jan 6, 2010
ValidForm Builder - Creating Forms With Validation
Viewed 890 times since Wed, Apr 21, 2010
Plupload - Multiple Files Upload Script
Viewed 1201 times since Tue, Feb 9, 2010
Web Usability Testing Tool - Clixpy
Viewed 1266 times since Sat, Jan 9, 2010
Free IP to Country, IP to City Database & API
Viewed 1229 times since Thu, Dec 31, 2009
What is new in HTML 5?
Viewed 960 times since Sat, Apr 3, 2010
Pastie - Pastebin to Share Source Code with Syntax Highlighting
Viewed 947 times since Mon, Jan 11, 2010
PHP Questions for Interview with Answers
Viewed 1199 times since Wed, Feb 24, 2010
MENU