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
Geo-location Mapping With Google Maps API & PHP
Viewed 1448 times since Mon, Apr 4, 2011
Review of Mobile Web Application Frameworks
Viewed 1428 times since Mon, May 9, 2011
PHP Questions for Interview with Answers
Viewed 1483 times since Wed, Feb 24, 2010
JavaScript Tree Menu Component - jsTree Menu
Viewed 1770 times since Sat, Jan 9, 2010
How to protect specific folder or disable directory browsing using htaccess?
Viewed 5264 times since Sun, Mar 14, 2010
Modify HTTP Headers in PHP with Examples
Viewed 1149 times since Wed, Mar 10, 2010
Free Under Construction Coming Soon Template
Viewed 1992 times since Sat, Mar 12, 2011
10 Most Popular JavaScript Frameworks
Viewed 1105 times since Thu, Jul 8, 2010
How to change the file type using htaccess?
Viewed 1061 times since Sun, Mar 14, 2010
How do I setup and use SSH?
Viewed 1659 times since Thu, Oct 15, 2009