2.13.2.17. Setting up a 404 page in Joomla!

You can customize the 404 page by redirecting to the page created:

To create a page inside CMS, do the following:

  1. Open the section "Materials(edit) → Material manager → Create material":
  2. Enter the data to create the desired 404 page:
    • "heading" — specify an arbitrary page title.
    • "Material" — in the editor block, specify the text that you want to display on the page.
    • "Condition" — select Publishedby... Otherwise, access to the page will be impossible.
    • "Category" — select the desired category. Most often it is best to choose Uncategorised.
    • "Access" — select Publicso that all site visitors have access. Otherwise, they will not be able to get to the 404 page, and the browser will display a page with an infinite redirect error.
  3. Switch to tab "Display" and hide unnecessary elements of this page: It is generally best to hide the following elements:
    • "Show labels".
    • "Introductory text".
    • "Material information header".
    • "Category".
    • "Category as link".
    • "Parent Category Title".
    • "Parent category header as link".
    • "Show associations".
    • "Author".
    • "Date of publication".
    • "Navigation".
    • "Show icons".
    • "Print icon".
    • "Number of views".
  4. Save the page by clicking "Save".
  5. As soon as the page is refreshed and the data is saved, pay attention to the browser line and remember the page number indicated after &id=X:
  6. Customize redirecting to this page, specifying as theaddress_established_pages string /index.php?option=com_content&view=article&id=Xwhere instead of X specify the previously saved page number.

To create your own 404 page (without using the Joomla template!), Create such a page, for example, in the root directory of the site with a name like 404-error.phpby using your own layout with the necessary information and visual design or by using third-party templates, for example bythese or bythese.

After creating the page itself customize redirecting to it, specifying as theaddress_established_pages filename, for example with the example given earlier /404-error.php.

By default, a 404 error is generated using the file error.php in the theme directory, but for the most part these files have a rather complex structure that ensures correct work with this particular theme.

To create the required call forwarding, do the following:

  1. Rename the file error.php active topic to another arbitrary name, for example error.php.bak.
  2. Copy the file templates/system/error.php to the directory with the active theme.
  3. Edit the file with the redirect lines:
    if (($this->error->getCode()) == '404') {
        header('Location: / address_established_pages');
    exit;
    }

    after the lines

    if (!isset($this->error))
    {
        $this->error = JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
        $this->debug = false;
    }
     
    $app = JFactory::getApplication();

    Instead /address_established_pages specify the desired address of the previously created page.

You can perform all these actions using filemanager or any FTPclient.

Content