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
AeroSQL - Web Based MySQL Management
Viewed 848 times since Wed, Feb 24, 2010
45 jQuery Navigation Plugins and Tutorials
Viewed 1876 times since Thu, Jan 28, 2010
10 AJAX based PHP WebMail Clients
Viewed 904 times since Mon, Jul 26, 2010
Meerkat - jQuery Plugin for Promotional Content
Viewed 743 times since Tue, Dec 29, 2009
Create Full Screen Slideshows With Supersized
Viewed 792 times since Tue, Jan 5, 2010
30 High Quality Charts & Graphs for Web Developers
Viewed 2287 times since Wed, Mar 23, 2011
What is Search Engine Optimization?
Viewed 1082 times since Fri, Jun 25, 2010
Protovis - Visualization for JavaScript via Canvas
Viewed 784 times since Sun, Jan 3, 2010
PHP Questions for Interview with Answers
Viewed 1038 times since Wed, Feb 24, 2010