Need a solution? Call Us Now!
1800 880 841

Joomla Coding Examples - Joomsef

Joomsef Meta Generator Fix/Modification for Joomsef Version 1.4.3

Joomsef is one of the best SEF components available for Joomla. SEF is "Search Engine Friendly".  This is used to change the default Joomla URL's, like "index.php?option=com_content&Itemid=26&id=12&task=view" into URLS like "".  Clearly SEF is vital in Search Engine Optimisation, reason, because search engines much prefer URL's like the latter.  They rank them much higher, can understand them and also pick up on keywords in the URL itself.

The Problem
The problem with Joomsef is that although it is great it has a down side.  The standard Joomsef component has advertising used in it and this is produced in the form of Meta tags in the pages displayed.  This can affect website ranking in search engines.  The Joomsef website says

"The latest open-source version of JoomSEF may contain links to ARTIO webpages or some of the JoomSEF development sponsors. Based on our policy, the older versions of JoomSEF available from our pages will be kept free of these links. You can also get the latest version without links of the JoomSEF from our webshop"

To gain a version without these sponsors shown in the output code you have to pay for it unless you follow the following patch.

The Solution
You need to locate the file "/components/com_sef/sef.php" and open it in a text editor.

Replace the contents of the whole file with the following.

 * SEF module for Joomla!
 * @author      $Author: michal $
 * @copyright   ARTIO s.r.o.,
 * @package     JoomSEF
 * @version     $Name$, ($Revision: 4994 $, $Date: 2005-11-03 20:50:05 +0100 (??t, 03 XI 2005) $)

// Security check to ensure this file is being included by a parent file.
if (!defined('_VALID_MOS')) die('Direct Access to this location is not allowed.');

$debug = 0;
// IIS patch.
if (isset($_SERVER['HTTP_X_REWRITE_URL'])) {
// OpenSEF patch.
define('_OPENSEF', 1);

if ($mosConfig_sef) {
    // VirtueMart redirection hack
    if( file_exists($GLOBALS['mosConfig_absolute_path'].'/components/com_virtuemart/virtuemart.php') ) {
        $_SESSION['vmhack'] = 1;

    $sefDirAdmin = $GLOBALS['mosConfig_absolute_path'].'/administrator/components/com_sef/';

    // Load language file.
    if (file_exists($sefDirAdmin.'language/'.$mosConfig_lang.'.php')){
    else {

    // load config data
    $sef_config_class = $sefDirAdmin.'sef.class.php';
    $sef_config_file  = $sefDirAdmin.'config.sef.php';

    if (!is_readable($sef_config_file)) die(_COM_SEF_NOREAD."($sef_config_file)<br />"._COM_SEF_CHK_PERMS);
    if (is_readable($sef_config_class)) require_once($sef_config_class);
    else die(_COM_SEF_NOREAD."( $sef_config_class )<br />"._COM_SEF_CHK_PERMS);

    $sefConfig = new SEFConfig();

    // check for kind of SEF or no SEF at all
    // test if this is Joomla! style URL
    if (strstr($_SERVER['REQUEST_URI'], 'index.php/content/')
    || strstr($_SERVER['REQUEST_URI'], '/content/')
    || strstr($_SERVER['REQUEST_URI'], 'index.php/component/option,')
    || strstr($_SERVER['REQUEST_URI'], '/component/option,')) {
    // or TIM style url
    elseif (strstr($_SERVER['REQUEST_URI'], 'index.php/view/')) {
    // otherwise operate as with JoomSEF URL
    else {

        $sef404 = $GLOBALS['mosConfig_absolute_path']."/components/com_sef/joomsef.php";
        if (is_readable($sef404)) {
            $index = str_replace($GLOBALS['mosConfig_live_site'], '', $_SERVER['PHP_SELF']);
            $base = dirname($index);
            if ($base == '\\') $base = '/';
            $base .= (($base == '/') ? '' : '/');
            $index = basename($index);
            $URI = array();
            if (isset($_SERVER['REQUEST_URI'])) {
                //strip out the base
                $REQUEST = str_replace($GLOBALS['mosConfig_live_site'], '', $_SERVER['REQUEST_URI']);
                $REQUEST = preg_replace("/^".preg_quote($base,'/').'/', '', $REQUEST);
                $URI = new Net_URL($REQUEST);
            else {
                $QUERY_STRING = isset($_SERVER['QUERY_STRING']) ? '?'.$_SERVER['QUERY_STRING'] : '';
                $URI = new Net_URL($index.$QUERY_STRING);

            if ($debug) {

            // Make sure host name matches our config, we need this later.
            if (strpos($GLOBALS['mosConfig_live_site'], $URI->host) === false) {
                header('HTTP/1.0 301 Moved Permanently');
                header('Location: '.$GLOBALS['mosConfig_live_site']);
            else include_once($sef404);

            if (($URI->path == $base)
            || ($URI->path == ($base.$index))
            || (@$option == 'com_frontpage')) {

            else {
        else die(_COM_SEF_NOREAD."($sef404)<br />"._COM_SEF_CHK_PERMS);
else {

     * Translate URL.
     * @param  string $string
     * @return string
    function sefRelToAbs($string)
        return $string;

Or you can download the full Joomsef modified component here.

More about web development

Joomla Services

Joomla Brisbane
Joomla Web Design
Joomla Sydney
Joomla Melbourne
Joomla Designer
Joomla Design
Joomla SEO
Joomla Development
Joomla Perth
Joomla Developer
Joomla Company
Joomla Websites
Want to know more?Call 1300 880 841 or click here to contact us.