Web Development

How to set a custom error page for your Joomla website?

If you want you can change the error page of your website. The error page can be used to lead visitors to other points of interest on your website. There isn't a setting in the Joomla control panel to do this but there is the following simple technique to achieve it. 

To change the error page you will first need to create a new article which will appear in its place.

  • Navigate to Content > Articles > Add New Article from the Joomla control panel menu. 
  • Type a Title and edit your new article the way you want your error page to look like. You can show an error image or type a message.
  • Then click the Publishing tab and find the Robots metatag and change it to No index, No follow. This way search engines will not index or show your page to search results.
  • Finally click the Save & Close option to save your new article.   
Now you need to create a new menu item, and then hide it from appearing in your website's menu. This is needed in order to get a link for your error page to use it in the next step. 

  • Navigate to Menu > Main Menu > Add New Menu Item
  • Type a Title for your error page (it doesn't matter what you fill in this field).
  • Click the Select button next to the Menu Item Type tag and select Articles > Single Article.
  • Then click the Select button next to the Select Article tag and select the error article you created in the previous steps.
  • Next change the Status setting on the right to Unpublished to hide your error page from the main menu of your website.  
  • Then click the Save button.
  • Now you will have to copy the URL address that is shown next to the Link field and note it somewhere to use it later on a next step.   
  • Finally click the Save & Close button to save your changes and close the editing page. 
The last step to create a custom error page is to edit the error.php file of the template you use. This file is located in your template's folder within the Joomla installation directory. The file path is usually joomla/templates/name_of_template_in_use/system/error.php or joomla/templates/name_of_template_in_use/error.php. (If there is not an error.php file you can create one in the joomla/templates/name_of_template_in_use/ folder). 
  • To open or create the error.php file you can use the File Manager tool through cPanel or an FTP client application.
  • Inside this file you should add the following lines of code for your error page. 

    defined('_JEXEC') or die('Restricted access');
    if ($this->error->getCode() == '404') {header('Location: /link');
    exit; }

  • Change the link field with the URL address you copied in the previous step above.
  • Finally save the error.php file.
To try your new error page by visiting a page of your website that does not exist. For example type an address for your website like and the error page you created will be shown.

IPGLOBAL IKE   |  IP.GR Web Hosting and Domain Name registration services in Greece
Cookies Preferences
 Functional  Statistics  Marketing

You can see detailed information about the use of cookies on the page: Terms of use