What is a .htaccess file?
.htaccess stands for hypertext access. This is the default filename of a directory-level configuration file which allows for decentralized management of web server configuration.
In simpler terms, the .htaccess file is placed inside a directory and can override some of the server's global settings. This allows each account the opportunity to modify certain settings that may be required for the site.
What can .htaccess do?
A .htaccess file can be set up manually by you, or there are several tools available in cPanel that will set up your .htaccess file for you.
Authorization and Authentication
.htaccess files can be used to specify the security restrictions for the particular directory, hence the filename "access." The .htaccess file is often accompanied by a .htpasswd file which stores valid usernames and passwords.
This can be set up automatically using cPanel. Under the "Security" section choose the "Password Protect Directories" button and follow the directions.
Rewriting URLs
.htacces can be used to rewrite long, overly comprehensive URLs to shorter and more memorable ones. Many popular CMS or Blogging scripts will set this up automatically.
IP Blocking
Use "allow/deny" in .htaccess to block IP addresses or other domains. Also, it can be used to block bad bots, malicious attacks, and referrers.
This can be set up through cPanel >> Security >> IP Deny Manager. Just follow the directions that you find under that tool.
Customized Error Pages
.htaccess can be used to specify a page that is shown when a server-side error occurs like a 404 Not Found. This can be set up through cPanel under Advanced >> Error Pages. Just select that option and follow the directions!
How to setup .htaccess files for my account
A .htaccess file can be set up manually by you or a web developer, but there are several tools available in cPanel that help to configure .htaccess file settings for you.
Note that if you manually set up your .htaccess file, you will be responsible for its content. Tech Support may be able to help with common errors caused by .htaccess, but we will not be able to support any customized settings. Tech Support will not be able to customize your .htaccess beyond the settings that are provided in cPanel. For further details on customizing a .htaccess file file, please see the links below.
If you wish to create a .htaccess file, you can do so easily using any text editing program you have. Open a new text document, add the settings, and save the file as plain text with the name ".htaccess" including the period before .htaccess, but minus the quotes. Once you have the file you can use FTP or the cPanel File Manager to upload that .htaccess file into the directory you want it to effect.
The .htaccess gives you a lot of control over what happens on your site BUT accidents do happen so make sure that you keep a backup of your .htaccess file whenever you are making changes. Before you modify it in any way make sure you have an older version that works correctly -- just in case you need to restore things.
.htaccess is also extremely sensitive. A missing semi-colon [;], an incorrect letter, or an extra backslash [/] can mess up the execution of the .htaccess file. Make sure that you enter the correct settings manually or let cPanel do it for you through the browser tools.
Additional Resources: