Other Applications
How to create a custom '404 page not found' page in Joomla! 3.x?

How to create a custom '404 page not found' page in Joomla! 3.x?

You can use the following instructions to create a custom 404 error page for your Joomla! 3.x website:

1. Create a new article – create new uncategorized article through your Joomla! 3.x administrative area > Article manager called 404. You can insert desired text inside it which will be displayed when such error message occurs. When you are ready, Save the article. The article will be accessible through a link similar to the following one:


where XX is the ID of the article. You can save this link because you will need it later.

2. Create a new Menu Item – create a new Menu Item through Joomla! 3.x administrative area > Menu manager called 404 Item (you can use the desired name). From the New Menu Item page, you have to link this item to the 404 article which you have already created. You can do that by choosing Single article from the Menu Item Type field and after that choosing the article 404 from the Select Article filed on the right side of the page.

3. Copy the default error.php file inside the folder of your current template – you need to copy the default error.php file from the templates/system/ folder inside the folder of the template which you are currently using with your website. For example, if you use a template called NewAtomic you will need to copy the error.php file from templates/system/ folder to templates/NewAtomic/. You can do that through your File Manager in Site Tools or using an external FTP client.

4. Edit the copied error.php file and place the necessary 404 detection code – you need to edit the error.php file which you have copied inside your template’s folder and place the following lines inside it:

  • For Joomla! 3.x 1.6, 1.7, 2.5, 3.x:
if (($this->error->getCode()) == '404') {header('Location: http://www.yourdomain.com/index.php?option=com_content&view=article&id=XX');

where XX is the ID of the article.

Place the above code according to your Joomla! 3.x version at the beginning of the error.php file right after the following lines:

/*** @package Joomla! 3.x.Site* 
@copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
defined('_JEXEC') or die;

After that, save the file and just browse to a nonexistent link from your website such as:


and you should see your custom error page.

Don’t forget to clear your Joomla! 3.x cache through the administrative area to see the changes immediately.

Share This Article