Skip to content

RootXcess

Home » CREATING A CUSTOM 404 PAGE in Joomla

CREATING A CUSTOM 404 PAGE in Joomla

Steps to create the 404 page in Joomla 

  1. Create an ‘uncategorized’ article in Joomla! to serve as your 404 page. Add some text like Sorry, the page you are looking for can not be found. You can also add navigation links to the article, so visitors have an easy way to return to your working pages.
  2. Create a menu item that links the new 404 articles and ‘apply’ your changes. Then copy the URL information (index.php?option….), set the menu item as ‘unpublished’, and close out of the menu editing page.
  3. Copy error.php to your templates directory. In your Joomla! installation copy the file error.php from the templates/system directory to your Template directory. For example, if I was using a template named ‘Cleancloud’ I would copy the error.php file to the templates/clean cloud directory.
  4. Modify error.php to Redirect 404 Errors to your 404 Article. Edit the error.php file as follows, adding the code below immediately under the ‘restricted access’ line:

If you are using Joomla 1.6, 1.7, 2.5, or 3.x please use this detection code:

if (($this->error->code) == '404') {
header('Location: /index.php?option=com_content&view=article&id=75');
exit;
}

Replace the location information (index.php?option..) with the URL from the menu item you created.

If you are using Joomla 1.5 and below please use this detection code instead:

if (($this->error->code) == '404') {
header('Location: /index.php?option=com_content&view=article&id=75');
exit;
}

What We Just Did 

In the above steps you are creating a custom article that shows up if the original article URL fails. When doing this the browser never actually sees a 404 error it just sees a page created on Joomla! This can help keep your SEO from having the negative effects of a bad URL or just the plain “page not found” message.