|
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
- Start by
logging into the Aplus.Net Control Panel at http://cp.aplus.net
using your Registration Number and Customer Password.
- Select Web
Hosting from the top navigation bar.
- Next, select Hosted
Domains and click on Manage Hosted Domains.
- 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.
- Click on the Custom
Error Pages icon.
- 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.
- 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.
- 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.
- 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:
- 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.
- To link your
custom error pages, you’ll need to insert the following code
into your .htaccess file (on one line only):
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.
- Save the
.htaccess file to your local computer.
- 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).
- Browse to the
directory that you’d like to customize.
- Set your
upload settings to ASCII. (Uploading .htaccess files in
‘binary’ format may have unexpected consequences.)
- Upload the
.htaccess file from your local computer.
- 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:
|