Hypertext Access or the .htaccess refers to the Apache Web Server software configuration file designed to implement configuration changes on a per-directory basis. A simple ASCII text file that contains the configuration directives controls the directory including sub-directories under the main directory.
Through an .htaccess file you can:
- Use a password to safeguard certain directories of your account.
- Set a hotlink protection.
- Create rules for redirection.
- Rewrite Uniform Resource Locators.
- Change the default index file.
- Modify error pages for your websites.
- Enable SSI.
- Limit access to your websites based on IP addresses
- Prevent directory listings
- Add Multi-purpose Internet Mail Extensions (MIME) types.
Most of the time, you need not undergo the .htaccess file editing because the necessary directives are added by the cPanel software automatically. For example, in creating password protected directories, cPanel will perform the required changes to the .htaccess file for you.
The .htaccess file syntax depends on the Apache Web Server software version and slightly differs from other releases. It is essential to determine the Apache version before making changes to the configuration file.
Application of Directives:
Hypertext Transfer Protocol Daemon looks for .htaccess configuration files in each directory, loading .htaccess files every time documents are requested. Configuration directives found in an .htaccess file apply to the file directory and sub-directories. However, there may be .htaccess files in other directories higher up.
Directives are applied in the order these are found.
An .htaccess file in a particular directory may dominate directives found in .htaccess files in the upper portion of the directory.
For example, in the directory /home/joltsupport/public_html/, we have an .htaccess file containing this directive:
Meanwhile, in the directory /home/joltsupport/public_html/test_directory/ there is an .htaccess file with the following directive:
The second .htaccess file makes sure the Apache web server will not follow all symbolic links in the directory /home/joltsupport/public_html/test_directory/. Once Options SymLinksIfOwnerMatch is in effect, it completely overrides any previous setting.
Altering an .htaccess file:
- Log into the cPanel control panel and allow the hidden files to be displayed as described in another article
- Click the .htaccess file so it will be highlighted
- Click the “Edit” button
- Text Editor window will pop up
- Scroll down to the bottom of the popped up window. Click the Toggle Help link and read the information carefully.
- Choose character encoding from the drop-down menu and click “Edit” button.