What is an htaccess file?
The htaccess file is a simple ASCII file which you can create using a regular text editor like NotePad. This file allows us to make configuration changes on a per directory basis. This file works on both Windows and Unix/Linux platforms with Apache Web Server.
Note: htaccess is not the name of a file. It is simple a file extension like .mp3. Only in this case, it is not something.htaccess or file.htaccess. It is simply named .htaccess. Also, if you are modifying an existing .htaccess file,make sure you make a backup of it somewhere before proceeding.
What can I use the htaccess file for?
There are several benefits of using the htaccess file for webmasters and developers. Most of them provide enhanced security to your site. You can prevent directory browsing, password protection for directories, change the default index page of a directory, redirect visitors for one page or directory to another and also prevent hot linking of images on your website.
How to create the htaccess file?
Open up a simple text editor, say Notepad and save it as .htaccess. While saving in say Notepad, remove under the save as option for .txt and save it under all files. Also remember to save under the ASCII mode and not Binary. Once uploaded to your server, make sure the permissions for your .htaccess file are 644 or (RW-R–R–). Having this makes the file writable by the server but not by others including visitors to your site.
Once created, where do I upload my .htaccess file?
Since the .htaccess allows us to drill down and implement changes on a per directory basis , there are multiple options for you to place this file. The only thing you need to remember is that a htaccess file in the root of your site affects your whole site whereas an htaccess file in your images folder is unique to that folder and its subdirectories if any.
/.htaccess(in the root of your site)
/content/.htaccess(in any content site, say membersonly/.htaccess)
/content/images/.htaccess(in an images folder)