404 Error Redirect link to home page

Joomla versions 2.5, 1.7 and 1.6 are all end-of-life since December 31st 2014 and are no longer supported. Please use Joomla 3.x instead.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Locked
suanhanhanh
Joomla! Apprentice
Joomla! Apprentice
Posts: 29
Joined: Fri Nov 30, 2012 1:24 am
Contact:

404 Error Redirect link to home page

Post by suanhanhanh » Thu Feb 21, 2013 4:16 am

Hello

I want to redirect to error page on the home page but have questions. My website use joomla 2.5.8

I'm the link / templates / system / error.php code:

defined ('_JEXEC') or die;
if (! isset ($ this-> error)) {
$ this-> error = JError :: raiseWarning (404, JText ::_('JERROR_ALERTNOAUTHOR'));
$ this-> debug = false;
}

now I have to see how it returned home ah? expect the pro only helps. Thanks

User avatar
Poznakomlus
Joomla! Apprentice
Joomla! Apprentice
Posts: 26
Joined: Tue May 29, 2012 10:25 am
Location: Ukraine
Contact:

Re: 404 Error Redirect link to home page

Post by Poznakomlus » Thu Feb 21, 2013 11:33 am

<?php
defined ('_JEXEC') or die;
if(!class_exists('ContentModelArticle')) require_once JPATH_ROOT.'/components/com_content/models/article.php';
$article = new ContentModelArticle;
if ($this->_error->get('code') == '404') {
//we receive the document with id=14 look material id дя 404 in the administrator of the panel
$youArticle = $article->getItem(14);
//We remove heading if it is necessary
echo $youArticle->title;
//We output the text
echo $youArticle->introtext;
}
else
{
//for all other mistakes a material with id=15
$youArticle = $article->getItem(15);
//We remove heading if it is necessary
echo $youArticle->title;
//We output the text
echo $youArticle->introtext;
}
?>
...............................................................
or
...............................................................
<?php
defined('JPATH_BASE') or die();
if ($this->_error->get('code') == '404')
{
echo file_get_contents(JURI::root().'/index.php?option=com_content&view=article&id=14');
}
else
{
echo file_get_contents(JURI::root().'/index.php?option=com_content&view=article&id=15');
}
?>

suanhanhanh
Joomla! Apprentice
Joomla! Apprentice
Posts: 29
Joined: Fri Nov 30, 2012 1:24 am
Contact:

Re: 404 Error Redirect link to home page

Post by suanhanhanh » Fri Feb 22, 2013 7:31 am

Your code, I pasted in error.I have finished processing. I add this code

 if (($ this-> error-> getCode ()) == '404 ') {
header ('Location: index.php');
exit;
}

Thanks


Locked

Return to “Installation Joomla! 2.5”