Need help? Chat now!

Hostwinds Tutorials

Search results for:


Table of Contents


Steps to create the 404 page
What We Just Did

Creating a custom 404 page (Joomla)

Tags Joomla 

Steps to create the 404 page
What We Just Did

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 pages. 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 articles and 'apply' your changes. Then copy the URL information (index.php?optio….), set the menu item as 'unpublished,' and close 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 were 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');
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 create a custom article that shows up if the original article's 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.

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.

Written by Hostwinds Team  /  April 24, 2018