By default, Apache comes with a set of standard error documents. They show up when the requested website page do not exist.

Often these response pages can be intimidating to site users. That’s where custom error-document helps. But, it needs additional configuration and often result in Apache error-document 404 not working message.

And, Bobcares’ Engineers fix Apache error-document settings as part of our Server Administration Services.

Today, we’ll see how we setup and fix Apache error-document 404 error.

 

Why custom Apache error-document ?

Firstly, let’s check on why we need a custom error document in Apache web server.

Website owners focus on user friendliness in every web page. As a result, they may wish to provide custom error responses in their website.

Luckily, Apache helps to set custom error document using the ErrorDocument directive. Users can set this for the entire server globally, for a single website, or in directory context. For site specific settings, it can be set in .htaccess file.

And, it allows to include custom error page that fits to the site layout.

The syntax of the ErrorDocument directive is:

ErrorDocument <3-digit-code> <action>

For example, in real servers it looks like

ErrorDocument 404 /404.php 

Here, 404.php is the custom designed web page.

 

What causes 404 error in custom error-document?

Now, its time to check the various causes that result in custom error document failure.After setting the custom error page, if the page is not accessible, it end up in a ‘Page not found‘ aka 404 error.

From our experience in managing Apache servers, the major reasons for Apache Errordocument 404 error are:

 

1. Wrong path

Unfortunately, a major share of problems with custom error-document happens due to wrong path setting of the error page. For instance, when the custom error page 404.php reside inside a sub folder, calling it by the path /404.php results in error. In short, relative path may create problems.  Therefore, path should be specified as the absolute path to your exact file. On a cPanel server, this would be something like /home/user/public_html/error_pages/404.php

 

2. Incorrect website settings

Similarly, even after designing custom error pages, some customers forget to enable it on the domain. This typically happens in servers with control panel. For example, in Plesk servers, improper setting of Custom error documents in Hosting Settings can cause trouble.

 

3. Browser error page settings

Again, turning on “friendly” error page in browsers can also be a reason for Apache Errordocument 404 not working.

For instance, “Friendly HTTP Error Message” is a feature that is enabled by default in Internet Explorer browser. If the server response to some common errors like 404 is less than 512 Bytes, then IE’s “friendly” error page is displayed instead of custom error page.

 

How we fix custom error-document for website

When customers report problems with custom error pages, our Dedicated Engineers follow a step by step procedure to figure out the problem. Let’s have a look at the exact steps.

    1. Check the direct link of the custom 404 page. When that is accessible, we rule out the possible coding problems with the custom web page. This means the problem lies with the configuration.
    2. We, then check the ErrorDocument settings in .htaccess file. Or ,if it is set in httpd.conf, we verify and correct the VirtualHost settings of the domain.
    3. Next, we set the full path to the error page in .htaccess file. Again, in servers with control panels like Plesk, we set the option correctly as shown below.

Again, even after correctly setting ErrorDocument,  if the problem exists, our Dedicated Engineers advise customers to turn off Internet Explorer’s friendly error message. For this, in Internet Explorer, Under Internet Options > Advanced > Browsing, uncheck the “Show friendly HTTP error messages” option.

[Having trouble with Apache ErrorDocument? We can fix it for you.]

 

Conclusion

In short, Apache Errordocument 404 not working error mainly happens due to wrong path setting, incorrect Apache configuration and many more. Today, we saw the typical reasons for the error and how our Support Engineers fix and make custom error page working.



Source link

Author

Write A Comment