Byron Posted May 31, 2009 Posted May 31, 2009 For all of those who are familiar with .htaccess. Here's a way to protect ALL files on your site that begin with 'private'. Add the code below to your root directory's .htaccess file. AuthType Basic AuthName "Restricted Access" AuthUserFile "/home/user/.htpasswds/public_html/passwd" <Files ~ "^(private).*$"> require valid-user </Files> # protect another file called info.php <Files "info.php"> require valid-user </Files> Here's a way to protect multible files: <FilesMatch "^(exec|env|private|phpinfo).*$"> AuthName "Restricted Access" AuthType basic AuthUserFile "/home/user/.htpasswds/public_html/passwd" Require valid-user </FilesMatch> The easiest way to set this up is to use the cpanel option to protect your public_html folder for password protection and then go back and edit the code to what I posted so all of your public_html folder doesn't reqire a password. Cheers, Byron
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now