[Web design] Remove ID from SEO friendly URL on Joomla 2.5-3.0

Note: this method only works on Joomla 2.5-3.0, for some reason, it doesn’t work on Joomla 3.1 and above, such as the newest version Joomla 3.3. Please let me know if you have good solution for new version, that I can update this post.

As you may know, Geekology is build by Joomla 2.5. During setting up, we found that after enable the SEO friendly URL (aka URL rewriting), there is always category ID/Article ID in front of the URL. That’s really annoying. Let’s remove it.

You need to modify the source file located at /JOOMLA_HOME_DIR/components/com_content/router.php

Three modifications need to be done:

1. In function ContentBuildRoute, replace line 27

$advanced = $params->get('sef_advanced_link', 0);

with

$advanced = $params->get('sef_advanced_link', 0);

2. In function ContentParseRoute, replace linke 208

$advanced    = $params->get('sef_advanced_link', 0);

with

$advanced    = $params->get('sef_advanced_link', 1);

3. Comment out lines from 228 to 232:

if (strpos($segments[0], ':') === false) {
    $vars['view'] = 'article';
    $vars['id'] = (int)$segments[0];
    return $vars;
}

You should have something like:

//if (strpos($segments[0], ':') === false) {
//    $vars['view'] = 'article';
//    $vars['id'] = (int)$segments[0];
//    return $vars;
//}

You are all set! Simple and easy!

« »

Leave a Reply

Your email address will not be published. Required fields are marked *