Joomla tutorials

Create your own 404 error in Joomla

Today we will with you to create your own error 404 in Joomla. It is intended that the user enter an incorrect path in the address bar of the browser got prepared us page.

Создание собственной 404 ошибки в Joomla

Here we go…
To start creating a material in the General category, i.e. it needs to be in a certain category of the site, and within the article directory. Call it 404 error and write any text you feel is necessary, when the user comes to this page.
For example, you can put a link on the main page of the site so that the user can always go back and find the material he needs.
Then copy the path that leads to our article, it should look something like this:
https://vassit/index.php?option=com_content&view=category&layout=blog&id=104&Itemid=75
You can put it into Notepad, then quickly copy if necessary. Put the display state to “published”.
Take the file error.php that is the system folder (templates/system) and copy it to the folder of your template, for example, in the folder templates/Vassallo/
Model in the file error.php line add the following code immediately after the line “restricted access” :
if (($this->error->code) == ‘404’) { header(‘Location: /index.php?option=com_content&view=article&id=75’); exit; ]
If you are using Joomla versions 1.6, 1.7, 2.5, then use the following code:
if (($this->error->getCode()) == ‘404’) {
Use the previously copied path with a material to specify the address code (Location). ID of the material you can learn when you create an article… I Have all the code looks as follows:
error->getCode()) == ‘404’) { header(‘Location: /index.php?option=com_content&view=article&id=211’); exit; ] //get language and direction $doc = JFactory::getDocument(); $this->language = $doc->language; $this->direction = $doc->direction; ?>
The final touch is added to the file robots.txt the string to search system not found our 404 error:
Disallow: /index.php?option=com_content&view=article&id=75

Did you like this?
Tip admin with Cryptocurrency

Donate Bitcoin to admin

Scan to Donate Bitcoin to admin
Scan the QR code or copy the address below into your wallet to send some bitcoin:

Donate Bitcoin Cash to admin

Scan to Donate Bitcoin Cash to admin
Scan the QR code or copy the address below into your wallet to send bitcoin:

Donate Ethereum to admin

Scan to Donate Ethereum to admin
Scan the QR code or copy the address below into your wallet to send some Ether:

Donate Litecoin to admin

Scan to Donate Litecoin to admin
Scan the QR code or copy the address below into your wallet to send some Litecoin:

Donate Monero to admin

Scan to Donate Monero to admin
Scan the QR code or copy the address below into your wallet to send some Monero:

Donate ZCash to admin

Scan to Donate ZCash to admin
Scan the QR code or copy the address below into your wallet to send some ZCash: