Byron Posted May 31, 2009 Share 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.