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
What is Search Engine Optimization?
Viewed 1310 times since Fri, Jun 25, 2010
Google Maps jQuery Plugin
Viewed 987 times since Thu, Jan 7, 2010
jDigiClock - HTC Hero Style jQuery Digital Clock
Viewed 1030 times since Tue, Feb 16, 2010
Modify HTTP Headers in PHP with Examples
Viewed 1030 times since Wed, Mar 10, 2010
Viewed 901 times since Sun, Jan 17, 2010
25 Graph & Chart Solutions For Web Developers
Viewed 32215 times since Mon, Feb 1, 2010
Create Navigation Menu Easily with jQuery Menu
Viewed 1053 times since Thu, Dec 31, 2009
Create Glowing, Radioactive Buttons with CSS
Viewed 976 times since Sun, Dec 27, 2009