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
5 (1)
Article Rating (1 Votes)
Rate this article
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
Which hosting plans support IIS Mod-Rewrite?
Viewed 6219 times since Sat, Oct 10, 2009
Review of Mobile Web Application Frameworks
Viewed 1643 times since Mon, May 9, 2011
PHP For Android Project - Interview with Lead Developer
Viewed 1291 times since Mon, Jul 26, 2010
New Tags Introduced in HTML5
Viewed 1584 times since Sat, Apr 3, 2010
Create Interactive JavaScript Charts With Highcharts
Viewed 1461 times since Fri, Dec 4, 2009
50 Free And Quality Web Icons
Viewed 1889 times since Tue, Jan 5, 2010
How to redirect an old domain to a new domain using htaccess?
Viewed 981 times since Sun, Mar 14, 2010
Speech Bubbles With Pure CSS3
Viewed 1197 times since Fri, Mar 12, 2010
Open Source Web Analytics Framework
Viewed 1094 times since Sat, Jan 30, 2010
jDigiClock - HTC Hero Style jQuery Digital Clock
Viewed 1327 times since Tue, Feb 16, 2010