Htaccess (HyperText Access) is a powerful file that can control many aspects of how your web site functions. Htaccess works with several types of servers, but is most commonly found in use with the Apache web server.
The htaccess file appears in a directory listing as what is called a dot file (.htaccess). The dot (or period) before the file name indicates that it is a hidden file, something that should not be accessible by users connecting to the server. This file is hidden because of the important role it fulfills. A user could easily “hack” or deface a web site by gaining unauthorized control over a htaccess file.
Please note that this is an overview of the htaccess file and what it can be used for. This article is not a guide for how to implement any of the common tasks below. If you are looking for specific information on how to accomplish any of the tasks listed here please see the references and tools links found towards the bottom of this page.
When used with a htpasswd file htaccess can be used to limit access to specific places in a web site.
Htaccess files can be used to rewrite long, complicated URLs into a more simple, shorter format. Quite often this is used to make web sites easier for search engines to index.
Custom Error Messages
You can create custom web pages that you would like to use and have the htaccess file tell the web server to use them instead of the default error pages.
You can create rules in the htaccess file which will only allow certain IP addresses or a range of IPs to connect to a site, or conversely, create rules to block specific IP addresses or a range of IPs. This is useful when launching a new web site and you only want to allow a small, specific set of users to connect to the site (provided you have or can obtain their IP addresses).
By default, apache looks for files called index.html, index.php, etc when trying to figure out what the “Directory Index” for that particular web site is supposed to be. Using the Directory Index statement in the htaccess file you can tell apache what file to use for the index.
This statement in an htaccess file tells apache to load newindex.php as the default page instead of looking for index.php or a similar index file (Note: There is no space between the two words when using them in an htaccess file).
Online Htaccess References & Tools
There are so many actions you can perform with the htaccess file that is next to impossible to memorize all of them (and more importantly how to implement all of them), so a good set of references and tools is extremely useful. A simple google search for htaccess will yield tens of millions of results, but here is a collection of links and resources that we use in the Liquid Web support department:
Remember, always backup your old .htaccess file before you start making changes!
Liquid Web’s support team is always available to assist customers with this or any other issue. If you need our assistance please contact us:
Toll Free 1.800.580.4985