The .htaccess file is a simple text file (in ASCII format). In general you can use, .htaccess files to change some configuration directives of the apache web server. However, .htaccess files can do lot more than simply change some settings of your web server as you will find from the topics listed in this tutorial.
Please, note that the name of the file is “.htaccess”. It starts with a dot. By default on Unix/Linux systems files starting with a dot are not publicly visible. If you are running a Windows PC, it is likely that you will have troubles creating such a file. So if you need to create such a file, create it directly on your web hosting server and modify it there, using your FTP program or some web based file manager.
If you place a .htaccess file in a sub-folder, its directives will override the ones that you have in your site main folder. That is if you disable directory listing globally for your site by placing the proper line in the .htaccess file in your main folder, you can then enable directory listing only for a particular sub-folder with another .htaccess file and the proper directive.
The .htaccess file can be placed on any folder on your site. It has recursive effect. This means that if you place the .htaccess file in your web root (the main folder of your web site) the directives and commands you place in the .htaccess file will have effect on all sub-folders.
The commands and/or directives in a .htaccess file are placed one at a line.
You can comment a given line in a .htaccess file using the hash symbol “#”. For example:
When somebody visits your site the Apache web server is checking if you have an .htaccess file somewhere in your web space starting from the root/main folder and traversing all the folders until it reaches the requested file. If an .htaccess file is found, its directives are applied to the current request.
It is important to know that the .htaccess file should be readable by the Apache server. So, please check with your host if they require any special permission set for .htaccess files. In general permissions of 644 should be working just fine.