htaccess: What it does & How to Use It

.htaccess is the default name for a file that is used to indicate who can or cannot access the contents of a specific file directory from the Internet.

.htaccess: Definition

The .htaccess file is a configuration file that resides in a directory and indicates which users or groups of users can be allowed access to the files contained in that directory.

One common use for an .htaccess file is to restrict access (password-protection) to specific files or directories on the Internet, or to specify a particular webpage to be accessed when there the file requested by the browser is not found (error 404).


The other popular use is to rewrite URLs - from shtml to html for instance, making it perfect for supporting SSI use.

Beware: htaccess files can be accessed by unauthorised users (hackers) and this is the reason some ISPs will not let you use them. If your ISP bans the use of htaccess, try using PHP Includes.

Using a .htaccess File

This file is named ".htaccess" (which is pronounced dot-h-t-access). It has no extension.

The .htaccess file lets you (for example) use .shtml extensions & it reinterprets those as if they were .html extensions. Basically, you say .shtml, but the computer thinks you said .html, so you avoid the file naming problems.

Now, you can't actually write a .htaccess file on a Windows (or Mac) machine, because these machines won't let you create a file with an extension but no name.

This is how to do this.

  • list iconCreate a text file (use Notepad) and save it as htaccess.txt
  • list iconCopy the following lines (exactly) & paste it into the text file:

    AddType text/html .shtml
    AddHandler server-parsed .shtml .html

Save the file as htaccess.txt, set your file transfer to ASCII (not binary,) and upload it to your website. Place it in the same folder as your website's index.html file. Now rename the file on your server. Change it to .htaccess (note the period at the beginning of the name) and save.

After you've uploaded and renamed the htaccess file, use your browser to visit your site. If you can see your website, it's okay. If nothing shows up, well, you've got to call your ISPs tech support and explain that you uploaded an htaccess file and ask them to restore the site.

How to make SSI pages                                        How to make PHP Includes pages

Webcritique.org is a Priday Design Studio service.
Priday Design Studio is based in Birmingham, UK and provides web design and site maintenance services for SME & club/associations throughout the UK. Domain names and hosting facilities are provided by associated site, PDS-Hosting Solutions, enabling us to provide you with a complete service.