|
Open the Article Manager in your Joomla! Administrator, and create a new Article. Select Uncategorized for the Section and Category. Add your 404 content to the Article and click the Save icon near the top right hand side of the Article Edit screen.
Optionally, Create a New Menu named errormenu or something similar to add your uncategorized 404 error page too. I do this in order to have the error page enabled and published, however when I set the Menu Assignment, I select 'None' so that my menu does not display on any pages in my Joomla! web site, and if you have SEF enabled, you can use the SEF URL to link to the 404 page if you wish.
Whether or not you created a menu solely for the 404 page, you need to Create a New Menu Item linking to the Article you created with the 404 content. You need to copy the Link: text (URL) from the newly created menu item to use in the following steps.
Now you need to locate the error.php file within your Joomla! installation and copy it to your template directory. The file is located in:
<joomla_dir>/templates/system/error.php
Copy the file to your template directory:
<joomla_dir>/templates/<your template>/error.php
Open the newly copied error.php file in your template directory and add the following code directly after the Restricted access line:
defined ('_JEXEC') or die('Restricted access');
if (($this->error->code) == '404') {
header('Location: The URL to your 404 article here');
exit;
}
?>
Finally, locate your robots.txt file, in the root directory of your Joomla! installation, edit the file, and add the following line:
Disallow: The URL to your 404 article here
If you followed these steps you should now have a custom 404 error page for your Joomla! website. You may notice however, that your new custom 404 page will show up in search results on your website.
Follow these steps to keep the 404 page from showing up in your Joomla! web site search results:
* Open the Plugin Manager (Extensions > Plugin Manager) from the toolbar in your Joomla! administration screen. * Locate the item named Search - Content, and open it to edit its properties. * On the right hand side, under the Plugin Parameters, set the Uncategorized Articles selection to 'No'
Now the 404 page will not show up in your search results, however this will disable ALL Uncategorized content from showing up, so if you have an article or articles that are Uncategorized, they will not be searchable using this method.
If you serve non-Joomla! content on your web site also, you can add the following line to your .htaccess (Apache) file, which will allow you to use your custom Joomla! 404 error page for your entire web site:
ErrorDocument 404 /The URL to your 404 article here
|