This is very simple.  For any file you want to have its own password protection, create an .htaccess file in the folder the file resides.  Just replace “pagename.html” for the file.  Then, just go to our .htpasswd password generator and create the .htpasswd file in the format:  username:password, where username is the name required to log in and “password” is the encrypted version of the password that shows in the tool in the link above under “Create new .htpasswd password file” and be sure to save your .htpasswd file in the absolute server path to the .htpasswd file.

AuthUserFile /home/user/path/to/.htpasswd
AuthName "name of login prompt"
AuthType Basic
<files “pagename.html”>
require valid-user
</files>

One more note, you don’t need to save the “.htpasswd” file by this name, any name will do.  Learn a lot more about .htaccess by visiting the official Apache website.  I like to put the commonly used snippets and tips on my site so they’re easy to find for me later.

–  Aaron Belchamber
www.AaronBelchamber.com


Trying to putty into your server, you may get a “Connection Refused” error.  That’s usually because the Open SSH server and client aren’t installed, just run this at the command line and restart Apache.

sudo apt-get install openssh-server openssh-client

In Linux, “cd” your way to the directory you want to completely clean out, then type:

$  rm –rf *

I suggest going into the directory first, then “ls” to list the contents so you can see what you’re deleting before using this command, though! Just a reminder, the prompt symbol is the “$” you don’t type that, on PCs or Macs it’s sometimes a % symbol instead.


Here’s a useful .htaccess snippet if you need to exclude a folder from your .htaccess rewrite.


RewriteEngine On
RewriteCond %{REQUEST_URI} !^/exclude-folder/.*$
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d

RewriteRule ^(.*)$ index.php/\