How to Remove the Article ID from SEF URLs in Joomla 3.7

Joomla 3.7 is a weird iteration of the famous CMS – it seems that quite a few important things were half baked or not completely tested. For example, the new routing functionality that was meant to be completely revamped in Joomla 3.7 was supposedly scratched from that version, to be later introduced in a future version (Joomla 3.8?). We are saying supposedly because there were some substantial changes to the routing functionality in Joomla 3.7, which left Joomla’s routing in a twilight state between Joomla 3.6.5 and Joomla 3.8. In fact, we were surprised when we saw the code because the lead developer in Joomla clearly stated in a blog post on the official Joomla blog that the new routing code will not be shipped with Joomla 3.7. He even stated (and we’re quoting his exact words) that the code itself also had some issues, some parts are pretty much unreadable and even with debugging not easy to understand. Yet it seems that some of that unreadable code made its way to Joomla 3.7.

In any case, the new routing functionality broke the URLs on some very important websites which were relying on the sef_advanced_link configuration variable in order to remove the article ID from the URL. This is because the sef_advanced_link configuration variable now belongs to the legacy router, which will only be used when the sef_advanced configuration variable is set to 1.

So, in order to remove the article ID from the URL in Joomla 3.7, you will need to do the following:

  • Open phpMyAdmin and select the database powering your Joomla website.
  • Click on the #__extensions table.

  • Open the row where the name field is set com_content.

  • Add the following to the params field (just before the curly bracket):

    ,"sef_advanced":"1","sef_advanced_link":"1"

    Explanation: The first parameter ensures that the legacy router is loaded, and the second parameter ensures that the “advanced SEF” is used (e.g. the “article ID” is removed from the SEF URL).

  • Save the row and then login to your Joomla website and clear your Joomla cache.

  • The issue should be solved. You shouldn’t see any article IDs in the URLs anymore.

Of course, if you’re a fan of core modifications (which is something that we do not recommend), then you can do the following instead of the above:

  • Open the router.php file that is located under the components/com_content folder.
  • Change the following:

    if ($params->get('sef_advanced', 0))
    {
    	$this->attachRule(new JComponentRouterRulesStandard($this));
    	$this->attachRule(new JComponentRouterRulesNomenu($this));
    }
    else
    {
    	JLoader::register('ContentRouterRulesLegacy', __DIR__ . '/helpers/legacyrouter.php');
    	$this->attachRule(new ContentRouterRulesLegacy($this));
    }

    to:

    JLoader::register('ContentRouterRulesLegacy', __DIR__ . '/helpers/legacyrouter.php');
    $this->attachRule(new ContentRouterRulesLegacy($this));

  • Open the file legacyrouter.php which is located under the components/com_content/helpers folder, and change both instances of the following line:

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

    to:

    $advanced = 1;

  • Login to the backend of your Joomla website and clear the cache by going to System -> Clear Cache and then clicking on the Delete All button.

  • That’s it! The article IDs should disappear from your URLs.

We hope that you found this post useful. If you need help with the implementation, then please contact us. We are always there for you, our fees are super affordable, our work is super professional, and we always have a solution!

9 Responses to “How to Remove the Article ID from SEF URLs in Joomla 3.7”
  1. Comment by Alex — May 15, 2017 @ 12:09 am

    There is another way now!

    Change “protected $noIDs = false;” to “protected $noIDs = TRUE;” at the top of file.

    That is all..

  2. Comment by Alex — May 15, 2017 @ 12:11 am

    Or change param “sef_ids” in #__extensions table

  3. Comment by Alex — May 15, 2017 @ 12:25 am

    Sorry! I checked again and now I can say, that this instruction is the only one way to fix the problem.

  4. Comment by mike — May 24, 2017 @ 12:33 pm

    I had problems with the phpAdmin section, adding ,”sef_advanced”:”1″,”sef_advanced_link”:”1″ before the curly brace. Should it be immediately to the right of the curly brace instead?

    Since I had problem with that method, I modified the core as directed and that worked fine.

    Thanks!

  5. Comment by Jim Dee — June 15, 2017 @ 3:14 pm

    Hey Fadi- Nice catch there! I actually have one site (just a personal site) where I removed the IDs. I was looking forward to no more core hacks in J3.7.x, but I hear this isn’t officially coming until 3.8. Ahh well, one more round of core hacks for that little site isn’t so bad. :-) Excellent content, as usual from itoctopus! :- -Jim

  6. Comment by Fadi — June 21, 2017 @ 5:21 am

    Hi Alex,

    We cannot confirm or deny whether any of your methods works. But we’ll try them time and we’ll comment back here if they work (or if they don’t work).

  7. Comment by Fadi — June 21, 2017 @ 5:37 am

    Hi Mike,

    Glad that it worked!

  8. Comment by Thanos — August 16, 2017 @ 12:11 pm

    Awesome! As a fan of core modifications as you say I chose the second way and it worked perfectly on my Joomla site – I am using the latest Version: 3.7.4.

  9. Comment by Sijmen — September 5, 2017 @ 9:47 am

    Thanks! You guys rock! :D Lets hope the SEF in 3.8 will be as awesome as promised! ;-)

Leave a comment