A Quick Introduction to htaccess

What are .htaccess files?

.htaccess files are plain text files you can use to make configuration changes to your server. Each line in a .htaccess file is called a directive. Directives are applied to the directory the .htaccess file resides in and any subdirectories within that directory.

How to create a .htaccess file

You can create a .htaccess file using any text editor. Windows Notepad or TextEdit for Mac OS X is a good choice. To create one, open your text editor, enter a few directives and save the file as .htaccess (with the period).

If your editor won't let you save the file as .htaccess, name it htaccess.txt instead. You can rename it after you've uploaded it to your server.

Using .htaccess files

To put a .htaccess file to work, you have to upload it to your server.

Before uploading a .htaccess file, always make sure there's isn't one already in the directory you're uploading it into. This can be tricky as many servers are configured to hide files with names that begin with a period. Here's how to set up your FTP client to show .htaccess files.

Once you've checked for an existing .htaccess file, you can upload your file (in ASCII mode) into the directory you want to work with, overwrite the existing .htaccess file, or add the directives from your .htaccess file to the one that's already on your server.

Now that you're familiar with htaccess, here are 5 htaccess tricks every webmaster should know.