.htaccess
.htaccess (note the dot) is a text file, each command is meant to be placed on a single line, so if your text editor has word-wrap, make sure it is turned off. If you want to use .htaccess you will need to be running an Apache server. IIS doesn't support it.
When you upload it to your server, make sure it is uploaded in ASCII mode rather than binary.
Another important thing to remember is the the .htaccess file affects the current directory and every directory below it.
Tutorials:
mod_rewrite
DirectoryIndex
htpasswd