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
13 Useful Javascript Syntax Highlighting Scripts
Viewed 1721 times since Mon, Jan 4, 2010
jQuery MultiSelect Plugin with ThemeRoller Support
Viewed 2652 times since Thu, Feb 4, 2010
ValidForm Builder - Creating Forms With Validation
Viewed 1185 times since Wed, Apr 21, 2010
How can I change session timeout value?
Viewed 1166 times since Tue, Apr 27, 2010
File Upload in PHP - PHP File Upload Script
Viewed 2699 times since Thu, Nov 5, 2009
Web Application Security Tools & Scanner Applications
Viewed 1610 times since Mon, Mar 22, 2010
PHP Script For PDF to HTML Conversion
Viewed 7272 times since Tue, Dec 15, 2009
mbSlider - Highly Customizable Content Slider
Viewed 1225 times since Mon, Jul 26, 2010
Tiny Flash MP3 Audio Player
Viewed 1208 times since Wed, Jan 6, 2010