Search The Hostwinds Guides Knowledge Base

Creating a custom 404 page (Joomla)

Share This Article [TheChamp-Sharing]

This guide covers the steps to create a custom 404 error page for your Joomla! installation. You might want to do this so the error page has useful site information. 

This Guide will send a 200 HTTP code to browsers instead of a 404 (since we are creating a page for browsers to load)

Steps to create the 404 page

  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 witch links the new 404 article and ‘apply’ your changes. Then copy the URL information (index.php?optio….), 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/cleancloud 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->getCode()) == '404') {
header('Location: /index.php?option=com_content&view=article&id=75');

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');

What We Just Did

The above steps you are creating a custom article that shows up if the original articles 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 negative effects of a bad URL or just the plain “page not found” message.

If we can help you in any way, please submit a ticket or join us in a Live Chat anytime. We are available 24/7/365 and we are dedicated to our client’s success; every client truly matters to us.