The Mysterious .HTACCESS file
by Bruce Hearder

Globally the Apache webserver software is installed on almost two thirds of all servers, and with Apache come the incredibly powerfull by very mysterious .HTACCESS file.
Most people only use the file for simple password protection, but i can be used for much more than that.
This article will help to show some of the possibilities that you can explore with your sites .HTACCESS file

One of the best features of the .htaccess (please not it must be all lowercase), is that file can be eddited on with almost any text based editor (such as the Notepad editor that comes will almost every installtion of Microsoft Windows.

Control the Download of certain FileTypes
With the following code snippet, the site owner can determine how the file is download.
This example (with files as .gz, .pdf, .zip and .rar) forces the file to be downloaded directly rather than having the browser attempt to open the file in the browser window.

<FilesMatch “\. (gz|PDF|zip|RAR) $” >
ForceType application/octet stream
</FilesMatch>

Allow users access to the server based on their IP address
The following code snippet allows only users of a certain IP address (in this case 27.101.84.200) access the the server.
All other users are rejected.

order deny, allow
allow from 27.101.84.200
deny from all

Deny Access to certain Files
The following code snippet, determined what files can be access. In this example, all access to files starting with "." symbol are declined. This will staop people from access (or viewing) your .htaccess file

<FilesMatch “^ \.” >
deny from all
</FilesMatch>

Allow Server Side Includes on your Site
This code line will ensure that files, which contain server Side Includes (SSI), awill also get processed with they carry the .html file extension
Addhandler server parsed .html

ErrorHhandling
When an error occurs on your website, such as a person tries to access a file that does not exist, then the .htaccess file can display a "customized" error page for that particular error:
For example :
Error document 404 /404error.html

Now when a user tries to access a file that causes a 404 error to be generated, the .htaccess file will now load an display the html file called 404error.html
Please Note: This file must live in the root directory of your website's structure (ie in a LINUX installation, in your /public_html/ folder).

Sometimes Microsoft Windwos has a problem with filenames that have a "." symbol as the first name.
To overcome this simply upload the file as something different and then rename the file when its on the server.