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
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
jqPlot - jQuery Charts & Plotting Plugin
Viewed 1669 times since Sat, Jan 9, 2010
Open Source WYSIWYG Editor
Viewed 1603 times since Thu, Jan 7, 2010
Inline Form Validation With jQuery
Viewed 1654 times since Sat, Jan 9, 2010
How to restrict access to your .htaccess file?
Viewed 1216 times since Sun, Mar 14, 2010
ProFolio - Instantly Create Free Portfolio Website
Viewed 1863 times since Sun, Jan 3, 2010
jQuery Dropdown Check List
Viewed 1673 times since Thu, Jan 14, 2010
Open Source Trouble Ticket System - Jutda Helpdesk
Viewed 2573 times since Sat, Jan 9, 2010
PHP For Android Project - Interview with Lead Developer
Viewed 1414 times since Mon, Jul 26, 2010
JavaScript Tree Menu Component - jsTree Menu
Viewed 2431 times since Sat, Jan 9, 2010
45 jQuery Navigation Plugins and Tutorials
Viewed 3281 times since Thu, Jan 28, 2010
MENU