Joomla 1.6.x 404 error custom redirect

Get a little fancy with your error page, don't settle for the default.

The Joomla part

To have control over your 404 error messages in Joomla do the following:

Create a new menu called “Hidden Menu” if it doesn’t already exist (you can ignore the module, J1.6+ just leave it un-created). Next create an Article called “404 Not found” and take note of the id number. Then create a menu item in the “Hidden Menu” pointing to the Article.

Copy the file at joomlaRoot/templates/system/error.php into your current site template.

Now edit that file, remove everything there and copy the following into it, change the aritcle id number, then save:

<?php
/**
 * custom error messages
 */
defined('_JEXEC') or die;
if ($this->error->getCode() == '404') {
    header('Location: http://www.mydomain.com/index.php?option=com_content&view=article&id=49');
    exit;
} 
?>

The .htaccess part

The above will cover the Joomla page errors like mydomain.com/notARealpage.html, but now you will want to trap errors like mydomain.com/products.htmlp5woops.

Add the following into your .htaccess file as it looks, change the article id number, save and try it out.

# Custom error redirects
ErrorDocument 404 /index.php?option=com_content&view=article&id=49