Useful information on htaccess file used in Apache based Web Servers

A Hypertext Access (.htaccess) is a configuration file which controls the directory it is placed in and all the subdirectories below it. It allows webmasters to control their website with actions like redirect pages, change the page extensions, password protect directories and much more. In this article, we have mentioned some useful information on .htaccess.

The .htaccess file which is used on Apache based web servers to run many features of the server. The file itself is just a small basic text file and can be edited by your hosts file manager or otherwise you can download the file, edit it and re-upload it.

The first you need to find out is if your host actually allows you to edit .htaccess files. Because of security measures, various hosts restrict in editing the .htaccess file to their customers. Then in such cases you must check the FAQs of your host or contact them to perceive if you have been allowed editing the file.

As a configuration file, .htaccess is very potent. Also the least syntax error (like a missing space) can result in displaying your content not correctly. Since .htaccess is a hidden system file, please make sure your FTP client is configured to show hidden files. This is usually an option in the program’s preferences/options. Create an empty text file using a text editor such as notepad, and save it as htaccess.txt. The reason you should save the file as htaccess.txt is because many operating systems and FTP applications are unable to read or view .htaccess files by default. Once uploaded to the server you can rename the file to .htaccess.

The .htaccess is case sensitive. For example, if a capital letter is shown for something; make sure it’s capitalized in your .htaccess file. Think about your caching needs carefully prior to setting it up. If your site is complete static, you can set longer cache period. One has to make sure to test the site right away after making any changes to the .htaccess file. A one mistyped character could make the difference between your site working and being down for hours before you understand what’s happened. One should constantly make sure to backup the .htaccess file before making any changes, because it can easily swap back in the old file.

The .htaccess file can perform wide range of things such as redirecting users automatically, custom error pages, password protecting folders, changing your file extensions, banning users with certain IP addresses, only allowing users with certain IP addresses, stopping directory listings and using a different file as the index file etc.