What is .htaccess?
Hypertext Access, commonly shortened to htaccess. .htaccess is a configuration file for use on web servers running the Apache Web Server software. When a .htaccess file is placed in a directory which is in turn ‘loaded via the Apache Web Server’, then the .htaccess file is detected and executed by the Apache Web Server software. These .htaccess files can be used to alter the configuration of the Apache Web Server software to enable/disable additional functionality and features that the Apache Web Server software has to offer. It’s an incredibly useful feature which allows webmasters to control how many aspects of their website works. You can 301 redirect pages, change the extensions of pages, rewrite urls, password protect directories, Error Document 404 redirect and much much more.
Using an .htaccess file, you can:
- Customize the Error pages for your site.
- Protect your site with a password.
- Enable server-side includes.
- Deny access to your site based on IP.
- Change your default directory page (index.html).
- Redirect visitors to another page.
- Prevent directory listing.
- Add MIME types.
.htaccess files are a simple ASCII text file with the name .htaccess. It is not an extension like .html or .txt. The entire file name is .htaccess. For more information on how to set up .htaccess files, visit Apache’s website.
The most common uses of .htaccss are to changed the DirectoryIndex and to enable apache’s mod_rewrite module to get user and search engine friendly url’s, but there are many other uses.