This tutorial will explain the steps required to create a custom 404 error page for your Joomla! (1.5) web site, using a Joomla! Article to display the content. You will need to be able to access the file system which houses your Joomla! web site in order to complete tihs tutorial.

engineachooInternet και Εφαρμογές Web

4 Δεκ 2013 (πριν από 3 χρόνια και 10 μήνες)

59 εμφανίσεις

Create a Custom 404 Error Page in Joomla!
This tutorial will explain the steps required to create a custom 404 error page for your Joomla!
(1.5) web site, using a Joomla! Article to display the content. You will need to be able to access
the file system which houses your Joomla! web site in order to complete tihs tutorial.

First, 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
1 / 3
Create a Custom 404 Error Page in Joomla!

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
sele
ction to 'No'
2 / 3
Create a Custom 404 Error Page in Joomla!


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
.h
taccess
(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
3 / 3