How to create a custom Joomla 404 page

Due to the unfriendly view of the default Joomla error page, I will recommend to create a custom 404 page, especially if you are constantly modifying/updating, un-publishing articles or menu items.

This tutorial will show you how to build a Joomla error page 404.

 

Step1. Create an uncategorized article:

You can name this article like 404 error page.  Make sure you add relevant information of the error page, something like:

Unfortunately the content is not available anymore; please visit my home page….

Also make sure you have the id of that article, you will need it soon!

Step 2. Create a menu item that link to the error page:

You will need to create an UNPUBLISHED menu item that is linked to the new error page.

Step 3. Copy the original 404 page:

Copy or download the code of file error.php from the following directory:

Templates/system

Step 4. Modify file and upload:

You will need to make a small modification to the file under the 'restricted access' line:

if (($this->error->getCode()) == '404') {

header('Location: /index.php?option=com_content&view=article&id=XXX');
exit;
}

Were XXX is your article id number from step 1.

Finally you will need to upload this new file into your template directory.