10

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?

5
  • Do you have any error? Commented May 23, 2014 at 9:17
  • Simply create a menu link for your article.
    – saibbyweb
    Commented May 23, 2014 at 10:08
  • Lodder - Yes, I get the link I want, but have 404 error page instead of my article.
    – gag
    Commented May 23, 2014 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
    Commented May 23, 2014 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 Commented May 23, 2014 at 12:35

3 Answers 3

11

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.

2
  • you're welcome @gag
    – saibbyweb
    Commented May 23, 2014 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
    Commented Aug 29, 2014 at 2:20
5

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.

1
1

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

2
  • Has this problem actually been fixed? I still have it with 3.10. Maybe I'm not seeing the option? (sorry about posting in this old thread, but it was the first that came up on Google)
    – Ralf
    Commented Sep 19, 2022 at 12:48
  • 1
    There are some circumstances where IDs are still shown. The easiest way to fix this is a third party extension such as the free or paid version of Alter Brains Direct Alias which is available for Joomla 3 and Joomla 4. Commented Sep 20, 2022 at 23:07

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