How to Make a Quick & Easy 404 Error Page for Joomla 3+

The error page is processed through the file error.php which if not already in your template folder, can be copied over from templates/system/error.php and further edited. However, I like to keep things simple by having it just load a specific article from my install of Joomla. Here’s how.

404 Error

Btw! Find the lengthy custom error page documentation on here.

And, this will work with Joomla 3.8. 3.9, 3.10 and beyond.

404 Within Content

For this all I need is to create the file error.php in my template root with the following content:

defined('_JEXEC') or die;

if (($this->error->getCode()) == '404') {
header('Location: /404');

and create an article with the a simple message like:

Error 404: Page Not Found
Unfortunately the page that you are trying to open does not exist.

As well as menu item pointing to the article, with the alias “404”.

404 on Individual Page

If for some reason I want the error page to be placed completely in it’s own page. An error.php like below should suffice:


if (!isset($this->error))
$this->error = JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
$this->debug = false;

// Get language and direction
$doc = JFactory::getDocument();
$this->language = $doc->language;
$this->direction = $doc->direction;

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>">

<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title><?php echo $this->error->getCode(); ?> - <?php echo htmlspecialchars($this->error->getMessage()); ?></title>

<!--- custom error page html here -->

Btw: I noticed that having Joomla in “Site Offline” mode will redirect 404s to index.php.  So to view the error page just open and test the forwarding function itself once your site is online.

Easy peach!

Leave a Comment