How To: Redirect Joomla 3.X 404 Page to Homepage
The quick and easy way to redirect any 404 page to your main homepage in Joomla.
- Inside your Joomla web directory, copy the error.php file from templates/system to root of your template directory (not your Joomla directory).
- Add the following detection code right below the statement defined( '_JEXEC' ) or die( 'Restricted access' );
if (($this->error->getCode()) == '404') {
header('Location: /index.php');
exit;
}
If you are using SEO URL’s, you can simply remove index.php leaving only the / in place.
- Try to browse your website with a link you know does not exist. It should instantly redirect your homepage now!
This is best practice for a website that does not have much content (static) or will never receive much content in the future.