Error page redirect with home page/ custom message give your site more professional than normal joomla site.
In joomla we can set via a single file named error.php. If you don't have idea about error.php file no need to worry just copy the file from yoursite/templates/system/error.php in to yoursite/templates/yourtamplatename/error.php.
if want display just html content just change the html content whatever you want in error.php.
if you want to redirect to any other pages like your home page just put following code immediate after
global $mainframe;
$mainframe->redirect('siteurl','your excuse message');
if you want redirect the other page based on error type just use switch case for redirect.
global $mainframe;
switch ($this->error->code) {
case '404':
$mainframe->redirect('redirecturl','your excuse message');
break;
case '500':
$mainframe->redirect('redirecturl','your excuse message');
break;
}
Technical tags:
In joomla we can set via a single file named error.php. If you don't have idea about error.php file no need to worry just copy the file from yoursite/templates/system/error.php in to yoursite/templates/yourtamplatename/error.php.
if want display just html content just change the html content whatever you want in error.php.
if you want to redirect to any other pages like your home page just put following code immediate after
defined( '_JEXEC' ) or die( 'Restricted access' );
global $mainframe;
$mainframe->redirect('siteurl','your excuse message');
if you want redirect the other page based on error type just use switch case for redirect.
global $mainframe;
switch ($this->error->code) {
case '404':
$mainframe->redirect('redirecturl','your excuse message');
break;
case '500':
$mainframe->redirect('redirecturl','your excuse message');
break;
}
Technical tags:
Very Good My Friend.
ReplyDeleteHey thanks a bunch, best answer I found on this issue, solved my case.
ReplyDeleteNice thanks
ReplyDelete