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
PHP Sound Captcha
Viewed 7555 times since Sun, Apr 11, 2010
Protovis - Visualization for JavaScript via Canvas
Viewed 887 times since Sun, Jan 3, 2010
10 AJAX based PHP WebMail Clients
Viewed 1033 times since Mon, Jul 26, 2010
Create Dynamic Tabs with jQuery
Viewed 862 times since Sat, Feb 6, 2010
How to change default web page using htaccess?
Viewed 1126 times since Sun, Mar 14, 2010
SEO Poisoning - What are SEO Poisoning Attacks?
Viewed 1164 times since Mon, Apr 5, 2010
Featured Items Widget with jQuery
Viewed 1158 times since Sun, Dec 27, 2009
Use PHP Functions In JavaScript with PHP.JS Library
Viewed 825 times since Fri, Jan 8, 2010
MENU