I am trying to remove the article id from a Joomla 3 URL. I searched around and the response is in

components\com_content\router.php

change 0 to 1 in $advanced = $params->get('sef_advanced_link', 1);

on lines 38 and 290

and also commented out

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

I consider it works fine in Joomla 2.5 as all comments mention this.

But it does not do the job for me on my Joomla 3.3 website.

How can I achieve this without creating menu items for each article?

  • Do you have any error? – Dmitry Rekun May 23 '14 at 9:17
  • Simply create a menu link for your article. – saibbyweb May 23 '14 at 10:08
  • Lodder - Yes, I get the link I want, but have 404 error page instead of my article. – gag May 23 '14 at 11:05
  • Saibbyweb - I have more than a 100 articles and the number is to grow up to 500, so I don't think it is a good idea to create menu for all these. – gag May 23 '14 at 11:06
  • If the extension K2 an option for you, then you can achieve this really easy. K2 has options for advanced routing, with the needed options. You can import you excisting articles into K2. Check my K2 Blog and the generated readmore links. Another solution is to use something like sh404sef or youwait for this indiegogo.com/projects/advance-the-joomla-url-router/x/7216161 – Joomla Agency May 23 '14 at 12:35
up vote 11 down vote accepted

Step 1

Edit “components/com_content/router.php“, then continue on step 2.
(You’ll probably have to re-do this step every time you update Joomla.)

Step 2

(There are two places need to do this change, one near the top, one in the middle) Replace this:

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

With this:

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

Step 3

Replace

->where($db->quoteName(‘alias’) . ‘ = ‘ . $db->quote($db->quote($segment)));

with

->where($db->quoteName(‘alias’) . ‘ = ‘ . $db->quote($segment));

and you're done.

  • Great, thanks a lot, it works perfectly. – gag May 23 '14 at 13:17
  • you're welcome @gag – saibbyweb May 23 '14 at 16:52
  • I have tried the above solution on my 3.3.3 site to no avail. The complete site would go blank. – user1833 Aug 29 '14 at 2:20

For anyone that don't want to get dirty with editing Joomla code, we shall mention that 3rd party SEF extensions provide the ability to remove the ids from the SEF urls.

There are plenty of SEF extensions someone can find in JED:

For example SH404SEF, is one of the most popular and used Joomla extensions, with long history and extended support by many 3rd party components.

As for a simpler solution, I recently came across a new plugin that provides a few features including "Remove ids from article, categories and tags SEF urls". Simple and easy solution that works.

*Note1: Both the extensions mentioned above are paid downloads.

*Note2: there is another a similar question in JSE.

In addition to the existing answers, a new router is included in Joomla 3.7.0 which will likely fix this problem.

Joomla 3.7.0 is due to be released soon. For details, see:

https://www.joomla.org/announcements/release-news/5695-joomla-3-7-0-alpha-2-released.html

protected by Community Dec 1 '14 at 3:58

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.