Home   >>   Section Blog   >>   New to Joomla!   >>   Joomla 404 special pages
Joomla 404 special pages PDF Print E-mail
Written by Mandville   
Saturday, 26 December 2009 19:41

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

Last Updated on Tuesday, 05 January 2010 13:49
 

Add comment


Security code
Refresh

Latest Posts

You need to modify this file
components/com_k2/models/item.php Read More ...
Due to the summer holidays, the next meeting is scheduled for the end of August.. Dont forget to bring back send a postcard and bring back a stick of rock for everone! Read More ...
We usually get sent phish emails to see if they are legit but here is a  good one. the email came from 123Greetings.com <ecards@123greetings.com>with an attachment ecard.zip which is a classic trojan virus. Read More ...
I was recently asked via twitter {xtypo_quote}@mandville how do u cope with the volume @ joomla forums?{/xtypo_quote} Read More ...
We dont send emails like this Dear Webmail/E-mail user,

This message is from our Webmail Messaging Center to all our account
owners.We are currently upgrading our database and e-mail center. We are
deleting all unused webmail account to create more space for new accounts. Read More ...

The Joomla!(R) name is used under a limited license from Open Source Matters in the United States and other countries. Securehotel.org.uk is not affiliated with or endorsed by Open Source Matters or the Joomla! Project.