Knowledgebase
Webinova Online Customer Support > Webinova Help Desk > Knowledgebase

Search help:


How to create a custom ’404 page not found’ page in Joomla

Solution

First, you need to create your error page like a normal article. Once you finish with its design, simply publish it. It will be then accessible via a link such as:

http://www.yourdomain.com/index.php?option=com_content&view=article&id=136

Now, you need to edit the templates/system/error.php file on your web hosting account. You can replace its code with the following:

<?php
/**
* @copyright Copyright (C) 2005 – 2008 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/

// no direct access
defined( ‘_JEXEC’ ) or die( ‘Restricted access’ );

if (($this->error->code) == ’404′) {
echo file_get_contents(‘http://www.yourdomain.com/index.php?option=com_content&view=article&id=136‘);
}
else
{
?>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=“http://www.w3.org/1999/xhtml” xml:lang=”<?php echo $this->language; ?>” lang=”<?php echo $this->language; ?>” dir=”<?php
echo $this->direction; ?>”>
<head>
<title><?php echo $this->error->code ?> – <?php echo $this->title; ?></title>
<link rel=”stylesheet” href=”/<?php echo $this->baseurl; ?>/templates/system/css/error.css” type=”text/css” />
</head>
<body>
<div align=”center”>
<div id=”outline”>
<div id=”errorboxoutline”>
<div id=”errorboxheader”><?php echo $this->error->code ?> – <?php echo $this->error->message ?></div>
<div id=”errorboxbody”>
<p><strong><?php echo JText::_(‘You may not be able to visit this page because of:’); ?></strong></p>
<ol>
<li><?php echo JText::_(‘An out-of-date bookmark/favourite’); ?></li>
<li><?php echo JText::_(‘A search engine that has an out-of-date listing for this site’); ?></li>
<li><?php echo JText::_(‘A mis-typed address’); ?></li>
<li><?php echo JText::_(‘You have no access to this page’); ?></li>
<li><?php echo JText::_(‘The requested resource was not found’); ?></li>
<li><?php echo JText::_(‘An error has occurred while processing your request.’); ?></li>
</ol>
<p><strong><?php echo JText::_(‘Please try one of the following pages:’); ?></strong></p>
<p>
<ul>
<li><a href=”/<?php echo $this->baseurl; ?>/index.php” title=”<?php echo JText::_(‘Go to the home page’); ?>”><?php echo JText::_(‘Home Page’); ?></a></li>
</ul>
</p>
<p><?php echo JText::_(‘If difficulties persist, please contact the system administrator of this site.’); ?></p>
<div id=”techinfo”>
<p><?php echo $this->error->message; ?></p>
<p>
<?php if($this->debug) :
echo $this->renderBacktrace();
endif; ?>
</p>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
<?php
}
?>

 

The text in bold is the additional code which should be added to the default file.

Now just browse to http://www.yourdomain.com/unexistent-link and you should see your custom error page.

Don’t forget to clear your Joomla cache in order to see the changes immediately.

 
Was this article helpful? yes / no
Article details
Article ID: 308
Category: General Joomla FAQ
Date added: 2012-12-11 15:45:49
Views: 385
Rating (Votes): Article rated 3.3/5.0 (7)

 
« Go back

 
Powered by Help Desk Software HESK - brought to you by Help Desk Software SysAid