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
Facebook Style Chat Script - ArrowChat
Viewed 1410 times since Tue, Aug 3, 2010
Advanced Backup System - PHP Backup Script
Viewed 1471 times since Wed, Jul 28, 2010
30 High Quality Charts & Graphs for Web Developers
Viewed 3686 times since Wed, Mar 23, 2011
10 AJAX based PHP WebMail Clients
Viewed 2014 times since Mon, Jul 26, 2010
Admin Skins - Constellation Complete Admin Skin
Viewed 1626 times since Thu, Aug 12, 2010
Featured Items Widget with jQuery
Viewed 1628 times since Sun, Dec 27, 2009
Speech Bubbles With Pure CSS3
Viewed 1258 times since Fri, Mar 12, 2010