How to password protect a single file with htpasswd and htaccess

1) Put your .htpasswd above your root so visitors can’t access it #/html/username/.htpasswd put username and encryped password of your members 2) It doesn’t matter how many files under how many directories you wanted to protect as they can share a common .htpasswd file #/html/username/public_html/test/.htaccess AuthName “Member Only” AuthType Basic AuthUserFile /html/username/.htpasswd require valid-user #/html/username/public_html/test/a.html is protected #/html/username/public_html/test/b.html and all others are NOT protected 3) /html/username/public_html/foo/.htaccess AuthName “Member Only” AuthType Basic AuthUserFile /html/username/.htpasswd require valid-user #/html/username/public_html/foo/bar.html is protected with the same .htpasswd in /html/username/ #/html/username/public_html/foo/others.html is NOT protected

Leave a Reply

Your email address will not be published. Required fields are marked *