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
5 (1)
Article Rating (1 Votes)
Rate this article
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
TinyBox - JavaScript Lightweight Modal Window Popup Script
Viewed 1894 times since Fri, Jan 8, 2010
Advanced Backup System - PHP Backup Script
Viewed 1348 times since Wed, Jul 28, 2010
New Tags Introduced in HTML5
Viewed 1544 times since Sat, Apr 3, 2010
PHP Quiz Questions and Answers
Viewed 4297 times since Mon, Jan 11, 2010
Geo-location Mapping With Google Maps API & PHP
Viewed 1618 times since Mon, Apr 4, 2011
JavaScript Tree Menu Component - jsTree Menu
Viewed 2052 times since Sat, Jan 9, 2010
jQuery Dropdown Check List
Viewed 1547 times since Thu, Jan 14, 2010
Speech Bubbles With Pure CSS3
Viewed 1163 times since Fri, Mar 12, 2010
Use PHP Functions In JavaScript with PHP.JS Library
Viewed 1060 times since Fri, Jan 8, 2010
Open Source Trouble Ticket System - Jutda Helpdesk
Viewed 2197 times since Sat, Jan 9, 2010