.htaccess files are frequently used to set up password protection for specific directories. If you are on a Windows-based platform or are not familiar with .htaccess files, you can use the Password Protection feature offered in the Hosting Control Panel.
.htaccess files are also used for the following:
- Error Pages
- Redirects
- Restricting Access
Note: Please review the following limitations and best practices when using .htaccess files.
- Changes made directly to an .htaccess file used for password protection will not be reflected in the Password Protection section of the Hosting Control Panel.
- .htaccess files must be uploaded in ASCII mode not binary mode, and the permissions need to be set at 644 (rw-r--r--).
- .htaccess files affect the directory they are placed in and all sub directories.
How Do I Use .htaccess to Display Errors?
Custom error pages are frequently used to provide additional information to visitors and to maintain the look and feel of your website.
Some of the more common customized error pages include the following:
206 Partial content | 301 Document moved permanently |
302 Document found elsewhere | 400 Bad request |
401 Authorization required | 403 Access forbidden |
404 Document not found | 408 Request timeout |
500 Internal server error | 501 Request type not supported |
When you create the custom error page, please consider the following common situations:
- Main navigation links
- Brief explanation of error
- Contact information, for example, email link to the Webmaster
- Site map or search function for the rest of your website
- Hyperlink to the page if the page has been moved
Save the custom error pages to your root directory. Once you have created your custom error pages, then the .htaccess file is used to activate these pages.
Perform the following steps to activate the web pages:
If the file exists you will need to edit it. If the file does not exist, you will need to create one using a basic text editor such as NotePad.
Note: The file name should be only .htaccess. If NotePad adds an additional extension to the name, you will need to remove it.
- ErrorDocument 404 /error404.html
- ErrorDocument 206 /error206.html
- ErrorDocument 301 /error301.html
- ErrorDocument 400 /error400.html
- ErrorDocument 403 /error403.html
- ErrorDocument 500 /error500.html
You have set up your custom error pages.
Note: Please review the following limitations and best practices when using .htaccess files:
- .htaccess files must be uploaded in ASCII mode not binary mode, and the permissions need to be set at 644 (rw-r--r--).
- .htaccess files affect the directory they are placed in and all subdirectories.