An .htaccess file is a 'hidden' file that controls various aspects of how the Apache server operates. File names that begin with a '.' are often hidden in FTP clients or file managers on your PC, so you may need to configure your application to be able to view these files.
To add an .htaccess file, create a new text file in your text editor of choice and name it '.htaccess', then upload it to the directory where you require it.
Some sample .htaccess commands...
Custom error pages (displays missing.html if a page can't be found):
ErrorDocument 404 /missing.html
Turn off directory indexes (useful to prevent image directory contents being displayed):
Redirect a web page to a different domain:
Redirect old-page.html http://www.yourdomain.com.au/new-page.html
Many of these commands can also be performed from within the cPanel interface. More complex commands such as mod_rewrite (commonly used for rewriting URLs) are also possible but you should familiarise yourself with the correct syntax first.
Within .htaccess files, the '#' character can be used to comment out a line or add comments to the file.