2.13.2.17. Setting up a 404 page in Joomla!
You can customize the 404 page by redirecting to the page created:
Automatically
Creating a 404 page inside the CMS
To create a page inside CMS, do the following:
- Open the section "Materials(edit) → Material manager → Create material":
- 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
Public
so 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.
- 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".
- Save the page by clicking "Save".
- 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
: - Customize redirecting to this page, specifying as
theaddress_established_pages
string/index.php?option=com_content&view=article&id=X
where instead ofX
specify the previously saved page number.
Manually
Creating your own 404 page manually
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.php
by 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
.
Setting the direction for a 404 error
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:
- Rename the file
error.php
active topic to another arbitrary name, for exampleerror.php.bak
. - Copy the file
templates/system/error.php
to the directory with the active theme. - 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.