How to Create a Custom 404 Page in Joomla

October 19, 2013 / How-to Guide

The page not found error is downright irritating and it could bug away visitors and they may never come back to your website. To reduce the trouble cause by a 404 error you could use a custom 404 error page instead of the boring and useless one. The page could provide the necessary details to guide the lost visitor and make sure they return to your site.

Before you create your own custom 404 page check the following things which you should have on a 404 page.

Search Box– If there is search option on your website then you should add it to the 404 page as well so the visitor can search what they are looking for on your site.

Sitemap link– It is essential that you have link to your sitemap and your homepage so the visitors can find a way to go back to the site and find what they want.

Follow these simple steps for designing you custom 404 error page in Joomla! 2.5.

  1. You need to create a file and name it error.php and place the file in the main directory of your template which is (/templates/your_template/error.php). You need to add the following code to the file:
    <?php// no direct accessdefined( ‘_JEXEC’ ) or die( ‘Restricted access’ );if ($this->error->getCode()==404) {

    echo file_get_contents(‘’);




    Make sure that you replace the URL with your website.

  2. Now create a message for the page with the title error or 404 or anything that you feel would work. You should place in a category which is not directly visible on your site.
    You might have seen error or 404 messages on sites like Reddit or Twitter which are quite creative and you could also create something along those lines to redirect your visitor to a relevant page on your site.
  3. Now make a menu hidden menu, one which is not published and  create an item with the name ‘error’ with an alias of error. If you want to use another alias then you need to change the above URL to reflect the same.
    Now give the type ‘Single Article’ to it and point it to your ‘Error’ article.

It’s all done now. Now whenever you have a broken link or there is a wrong link used by a visitor then they would see your custom error page with a catchy message that would redirect them to a proper page instead of the crappy server error which usually bugs visitors off.

If you have any other issues when you build a website or related to website hosting then you can refer our Web Hosting Blog and you can contact us for any query we would do our best to help you get your website fixed.

Spread the love