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
Geo-location Mapping With Google Maps API & PHP
Viewed 916 times since Mon, Apr 4, 2011
SEO Poisoning - What are SEO Poisoning Attacks?
Viewed 917 times since Mon, Apr 5, 2010
ICEpdf - Open Source Java PDF Library
Viewed 916 times since Wed, Jan 6, 2010
How to restrict access to your .htaccess file?
Viewed 651 times since Sun, Mar 14, 2010
Coming Soon Template
Viewed 688 times since Thu, Nov 12, 2009
Web Application Security Tools & Scanner Applications
Viewed 972 times since Mon, Mar 22, 2010
Google Maps jQuery Plugin - gMap
Viewed 917 times since Mon, Feb 8, 2010
Free JavaScript Charts Library - JS Charts
Viewed 660 times since Sun, Dec 13, 2009
MENU