Joomla: Custom Http Error Code Page

The default http error code page is located at templates/system/error.php. Joomla will show this for any http errors encountered. You can just modify this or can create a error page for each template. The advantage of creating a error page for each template is that you can display an error message that is integrated into your page, instead of the ugly stand alone error message.

You can create a custom error message by creating a error.php in your home page template directory like
this /templates/tempname/error.php. This will override the default error.php.

Custom error message

Can create a custom error message like this in error.php:

<?php if ($this->error->code == '404') { ?>
        <div id="errorboxheader">Page not found</div>
                <div id="errorboxbody"><p>Sorry! That page cannot be found.</p>
<?php } ?>

You can also make the error message appear to be integrated into your site. With the use of JModuleHelper::renderModule() you can actually insert the template modules you need to make it appear they are still at your site but an error was encountered. If your using this method then its best you create error.php for each template. You insert modules into your error.php like this:

foreach (JModuleHelper::getModules('top') as $module)  {
    $module = JModuleHelper::renderModule($module, array('style' => 'xhtml', 'id' => 'section-box'));
    echo $module;

This will insert the module named top into the error.php file. Basically you recreate the basic structure including style sheets and minimum modules needed in your error.php. You place the custom error message in the main content area surrounded by your modules in the error.php file.

Just return error code

You can also just return the error status code to the browser. Place this at very top of error.php.

if ($this->error->code == '404') {
        header("HTTP/1.0 404 Not Found");
} ?>

Leave a comment


  1. Pretty! This was an extremely wonderful post. Thanks for providing these details.

  2. At Instagram you can see interesting posts.