Tuesday, 5 March 2013
What is .htaccess File, Introduction to .htaccess file
It is easy to introduce .htaccess file. .Htaccess file is a web configuration file used by apache web server. It is also known as hypertext access file. It is used to control security, behavior and performance of a website. It is easy for webmasters to create .htaccess file. This file does not have any extension name like .txt and .html. It is simply called ".htaccess". It is small text file, you can edit it via your hosts file manager or can download it and after editing reupload it. It should be in ASCII format.
.htaccess file can be placed in any folder of your website. It has recursive effects. It means if you placed this file in your main folder or root then the commands you mentioned in file will affect all sub folders. You can also placed this file in sub folders. If you upload this file to any sub folder, Then the directives and commands will override from the once that you have in your main folder. You can only enable directory listing for a sub folder with another .htaccess file add the proper commands or directives. The directives or commands in .htaccess file should be placed one at line.
There are various features of .htaccess file. The features include:
--- It can be used for security purpose and has ability to password protect folders.
--- You can ban users from certain IP addresses.
--- You can also allow users of certain IP addresses.
--- You can cover custom error pages by making .htaccess file. You can use custom error pages for any error.
The errors can be as:
1) 401 - Authorization Required
2) 403 - Forbidden
3) 404 - Wrong Page
4) 500 - Internal Server Error
5) 400 - Bad Request
--- Stop a directory to be indexed
--- You can use htaccess for redirection. Redirect users to another pages or directory automatically.
--- You may also use different file as index file.