Categories: Joomla

How to create a custom 404 page in Joomla?

Creating a 404 page in Joomla is essential as it tells the users that the page they are visiting isn’t found or broken. In this tutorial, I will explain to you the steps to create a 404 page. If the page isn’t found instead of 404 server error, a 200 HTTP code will be sent to the browser. This will also tell the search engine that page isn’t allowed to be crawled. So, now let us create it.

Step 1: Create an Uncategorized Joomla article

The first step is to create an article in the Uncategorized category. Set the title of the article to “404 – Page Not Found” and the alias to “404”. Add images or text which says “Sorry, the page isn’t found” or anything that you wish.

Step 2: Set the Robots to No Index, No Follow

The robots tell the search engine to either allow or disallow the page to index. As we don’t want the 404 to be indexed by the search engine. We have to set the Robots to No Follow, No Index in the Publishing tab of the Joomla article and Save the article.

Step 3: Create a Menu item

Once you have saved the article, create a Hidden Menu. To create it you can now go to Menus> Manage > Add Menu and fill the menu type and description.
After creating the Hidden Menu, navigate to Menus > Hidden Menu > Add New Menu Item

  • Add the Menu Title and Alias
  • Select the Menu Item Type as Single Article
  • Save the article and copy the Link (index.php?option=com_content&view=article&id=292)

Step 4: Create the error.php file

The error.php file is usually located in templates/YOUR_ACTIVE_TEMPLATE/error.php. If it doesn’t create an error.php file and add the following codes into it. Replace your link with your link into the header function below.

defined( '_JEXEC' ) or die( 'Restricted access');
if ($this->error->getCode() == '404')
{
header('Location: /index.php?option=com_content&view=article&id=292');
exit;
}

Save the file after adding the codes into error.php file of your template.

Step 5: Test your page

Once you have added the codes, test your website. Try to open a page which doesn’t exist. For example, www.yoursite.com/hahaha. If the site opens the 404 pages you have created, then everything works fine. If it doesn’t recheck the steps or contact us. We will help you out 🙂

Abhilash Sahoo

Abhilash Sahoo, with 14 years of experience, is a Certified Joomla and WordPress Expert and the Founder & CEO of Infyways Solutions, specializing in innovative web development solutions.

Share
Published by
Abhilash Sahoo

Recent Posts

HubSpot vs WordPress: A Comparison Overview of Popular CMSs.

HubSpot vs WordPress? What best? Indeed, for more than ten years, WordPress has been the…

3 months ago

Boost Your Website’s Performance with Expert WordPress Speed Optimization Services

WordPress Speed Optimization Services for Website maintenance is a full-time job. Apart from introducing new…

3 months ago

Fixing There Has Been A Critical Error On This Website WordPress

Nothing is more terrifying than when your WordPress website is going down, especially when you…

4 months ago

WordPress vs Ghost: Exploring the Differences!

WordPress vs Ghost, who wins actually? Despite its current position as the world's leading content…

4 months ago

Top WordPress Security Services Providers in 2023

The security and safety of any website are essential for its health and well-being. The…

4 months ago

Top 12 WordPress Website Management Tools for 2023

Let's explore the definition of WordPress Website Management Tools before moving on to the finest…

6 months ago