Home » Categories » Business » Web Development

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

<Files secure.php>
AuthType Basic
AuthName “Prompt”
AuthUserFile /home/path/.htpasswd
Require valid-user
</Files>

# password-protect a directory

resides
AuthType basic
AuthName “This directory is protected”
AuthUserFile /home/path/.htpasswd
AuthGroupFile /dev/null
Require valid-user
Attachments Attachments
There are no attachments for this article.
Comments Comments
There are no comments for this article. Be the first to post a comment.
Related Articles RSS Feed
Google Skipfish - Web Application Security Scanner
Viewed 853 times since Mon, Mar 22, 2010
Open Source Online Invoice System - siwapp
Viewed 1186 times since Thu, Jan 7, 2010
UI Patterns - User Interface Design Pattern Library
Viewed 866 times since Thu, Dec 31, 2009
File Upload in PHP - PHP File Upload Script
Viewed 3407 times since Thu, Nov 5, 2009
Coming Soon Template
Viewed 1195 times since Thu, Nov 12, 2009
What is jQuery?
Viewed 518 times since Tue, Dec 1, 2009
50 Free And Quality Web Icons
Viewed 871 times since Tue, Jan 5, 2010
What is new in HTML 5?
Viewed 573 times since Sat, Apr 3, 2010
13 Useful Javascript Syntax Highlighting Scripts
Viewed 1718 times since Mon, Jan 4, 2010