post your comment   print   send to a friend
Rate:  50% | Views: 751
Question categories:  Unix Plans

CAN I USE AN .HTACCESS FILE TO CUSTOMIZE MY OWN ERROR DOCUMENTS?

Answer by: Stuart Pierce, Aplus.Net Knowledge Base Support

An .htaccess file can be used to return a variety of custom error documents for your site.

However, for all of your files contained within the /html directory (e.g. excluding subdomains), we strongly suggest that you use the Custom Error Pages tool available in the Aplus.Net Control Panel. The tool will appropriately create the necessary .htaccess file without any need for coding on your part. Here’s how it works:

I. Using the Control Panel

  1. Start by logging into the Aplus.Net Control Panel at http://cp.aplus.net using your Registration Number and Customer Password.
  2. Select Web Hosting from the top navigation bar.
  3. Next, select Hosted Domains and click on Manage Hosted Domains.
  4. Now, select the domain name associated with the website that you’d like to create a custom error page at.

NOTE: If your actual domain name does not yet resolve to Aplus.Net’s servers, you must use your utility domain (yourftpusername.web.aplus.net) that is associated with your Unix-based hosting plan.

  1. Click on the Custom Error Pages icon.
  2. You’re now ready to start linking your custom error pages. First, select the Server Error type that you’d like to have associated with this page.
  3. Choose the website section you'd like to use the Custom Error Page for. You have two options:
    • To use Custom Error Page for your entire website.
    • To use Custom Error Page for a specific website section.
  4. Next, under the Select your Custom Error Page section, select the location of your custom error page to be displayed. First, you have to specify the directory, and then to choose the exact custom error page file within that directory.

Important: Your custom error page file has to be already uploaded to the specific directory.

Note: Please have in mind that some browsers do not display properly the error page file, if it is too small. The minimum file size for a custom error page file is 512 bytes.

  1. Finally, click the Create Custom Error Page button.

II. To add custom error pages for subdomains hosted in your web space, you will need to create .htaccess files by yourself. Here’s how:

  1. Begin by either creating or opening a local copy of an .htaccess file. (If you’re editing an existing file, we recommend editing it using the “Edit” function found in the File Manager on the Control Panel.)

    Important: Remember that a .htaccess file affects both its own directory and all of subdirectories contained in that directory. In order to make sure that you set the scope of your custom error pages appropriately, make sure you put your .htaccess file in a directory that dominates only the directories that you want to have associated with the custom error pages.

  2. To link your custom error pages, you’ll need to insert the following code into your .htaccess file (on one line only):

ErrorDocument code path

You will need to adjust the following:

  • Code: Specify the three-digit code of the HTTP Response code error that you’d like to have associated with the custom document.  More details on HTTP response codes are available here: HTTP Response Codes.

  • Path: Specify the relative path to the custom document that you’d like to appear when the error occurs.

Here’s an example of what the .htaccess file code should look like for custom error documents (stored in the html/errors directory) for 404 (Page Not Found) and 500 (Internal Server Error) errors:

ErrorDocument 404 /errors/404error.html

ErrorDocument 500 /errors/500error.html

If you don’t want to have your error messages pointing to a separate HTML file, you can specify HTML code after the error code number instead.  (Be sure to have the code fit on only one line without any word wrapping.)

ErrorDocument 404 <body><h2>Go away!  There’s no page here!</h2></body>


Note: Please have in mind that some browsers do not display properly the error page file, if it is too small. The minimum file size for a custom error page file is 512 bytes.
  1. Save the .htaccess file to your local computer.

  2. Open your FTP client and establish a connection to your web space using your FTP Username and FTP Password. Your connection URL should be www.yourdomainname.com (where ‘yourdomainname.com’ = the actual name of your domain).
  1. Browse to the directory that you’d like to customize.

  2. Set your upload settings to ASCII. (Uploading .htaccess files in ‘binary’ format may have unexpected consequences.)

  3. Upload the .htaccess file from your local computer.

  4. After the upload is completed, you may need to change the file permissions for the .htaccess file. They should be set to 644 (using chmod) or RW-R--R--.

Important: If you have a Windows-based hosting plan, you cannot use .htaccess files.

Related links:

Customer Feedback
Rate:  50% | Views: 751 | Please Rate:  
 
If you have other comments or ideas for future technical tips, please type them here:

Email: (optional)

Comments: (optional)

 Domain Name Registration | Server Hosting    Back to serch results
Browse the Base
Knowledge Base
Shared Hosting
  Unix Plans
    MySQL
Messages
 

Blogging at Aplus.Net

Don't forget to check out our blog ! Keep up to date at Aplus.Net.

Private Area
 
Ask
in Private
   
Personal
Folder
 
Related Questions
 
1. I have a Unix-based shared hosting plan. How can I change permissions for files/directories using the File Manager?
 
2. How can I protect directories?
 
3. How to Set Up a Storefront ?
 
4. What are the permissions on files and directories?
 
5. In Unix, what is the find command, and how do I use it to search through directories for files?
 
Home Browse Search Ask in Private Personal Folder   Help
powered by web hosting 
  Logged as: Guest