You might think, that this is an easy job, you just set up sh404SEF, and you're done! Maybe... but sometimes this might be really wrong. Especially if you have a multilingual site, and a properly built Joomla 1.7+ template.

Why? Simple: a properly built Joomla template has an extra file in the template root, called error.php, meant to catch and handle your page's errors - among them the 404 - Page not found errors. So you might set up everything correctly, even you might have a nice, personalized 404 error page by using the sh404SEF's API, but you still might see your template's error page instead. Worse, it's not just a taste-thing, most serious SEO tools will see your site as NOT having a properly set 404 error page, which is definitively a serious problem.

So, what you can do? Is simple. When installed, sh404SEF creates an extra category, called "sh404SEF custom content" and places inside that category the default sh404SEF error page. This will be your starting point. You can personalize it, you can even change the name of the file (just be sure to tweak your sh404SEF settings accordingly), but at last step, be sure, you create a menu link pointing to it somewhere. Can be in a hidden menu, you need this to be able to assign module positions and other Joomla behaviors to your 404 error page. At the end note the URL leading to the page, will be something like:

index.php?option=com_content&Itemid=621&id=56&lang=en&view=article

If you have a multilingual site, you can just duplicate the default error page, and personalize them properly, in this case you will have as many content items and menu items linking to them, as many languages your site is using. To keep things simple, let's say that you have a bilingual site, English and Hungarian, so the second URL you will have will be something like:

index.php?option=com_content&Itemid=627&id=57&lang=hu&view=article

Once you have done this, you need to do an edit in your template. Grab your preferred editor, and open your template's error.php file. Delete everything you find there - you won't need it anymore. Depending on what you have - a monolingual or a multilingual site, you will paste here the following code.

a. The monolingual site (let's say an English one)

<?php
// No direct access.
defined('_JEXEC') or die;

/* The following line gets the application object for things like displaying the site name 
- this time we use it to forward the request to the error page */
    $app = JFactory::getApplication();

/* Location of error article */
    $error = JRoute::_('index.php?option=com_content&Itemid=621&id=56&lang=en&view=article');

/* Redirect to error article */
    $app->redirect($error); 
?>

b. A multilingual site (English as the default language, Hungarian the second one)

<?php
// No direct access.
   defined('_JEXEC') or die;

/* The following line gets the application object for things like displaying the site name 
- this time we use it to forward the request to the error page */

   $app = JFactory::getApplication();

/* Location of error article */
   switch ($this->language) {
     case "hu-HU":
                 $error = JRoute::_('iindex.php?option=com_content&Itemid=627&id=57&lang=hu&view=article');
                 break;
     case "en-GB":
     default:
                 $error = JRoute::_('index.php?option=com_content&Itemid=621&id=56&lang=en&view=article');
                 break;
    }

/* Redirect to error article */
   $app->redirect($error); 
?>

Save your file, and enjoy!

0
0
0
s2sdefault
Category: Template trickery