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
5 (1)
Article Rating (1 Votes)
Rate this article
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
Quick Tables for Showing & Updating DB Data
Viewed 1281 times since Sun, Dec 27, 2009
Admin Skins - Constellation Complete Admin Skin
Viewed 1420 times since Thu, Aug 12, 2010
Search Engine Optimization: Tags of Importance for SEO
Viewed 1104 times since Tue, Oct 12, 2010
Advanced Backup System - PHP Backup Script
Viewed 1303 times since Wed, Jul 28, 2010
Free JavaScript Charts Library - JS Charts
Viewed 1178 times since Sun, Dec 13, 2009
13 Useful Javascript Syntax Highlighting Scripts
Viewed 1562 times since Mon, Jan 4, 2010
Open Source Web Analytics Framework
Viewed 1022 times since Sat, Jan 30, 2010
Google Maps jQuery Plugin
Viewed 1194 times since Thu, Jan 7, 2010
10 Most Popular JavaScript Frameworks
Viewed 1187 times since Thu, Jul 8, 2010