Wednesday, March 9, 2011

Redirect error page to some other page in joomla

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
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:
custome error controll in joomla, error page redirect , 404 error redirect , 500 error page redirect

The Official Joomla! Book (Joomla! Press)Joomla! 1.5: A User's Guide: Building a Successful Joomla! Powered Website (2nd Edition)Joomla! Start to Finish: How to Plan, Execute, and Maintain Your Web Site (Wrox Programmer to Programmer)

3 comments: