Get rid of ID (category and article) from URL (Joomla 3.3 / 3.4 / 3.5)
Asked 07 September, 2021
Viewed 918 times
  • 42
Votes

I have a Joomla 3.3.6 (edited: 3.5.) site organized in only 3 levels:

  • Four big categories (i, ii, iii, iiii)
  • Each one divided in some intermediate categories (A, B, C, ...)
  • And finally articles
  • Two languages (en, pt)

The URL after setting Search Engine Friendly URLs, Use URL rewriting, Adds Suffix to URL and multilanguage support, should be in the form:

http://www.example.com/en/bigcatiii/intercatA/articlex.html

But as many others that have Joomla installed and ask for a solution since Joomla-Baby-Version, I got:

http://www.example.com/en/bigcatiii/666-intercatA/articlex.html

where 666 is a number from hell indicating for no purpose a category ID

Now browsing for an answer, I found this answer:

 Edit “components/com_content/router.php“
 (You’ll probably have to re-do this step every time you update Joomla.)
 Replace the lines 38 and 290 with:
 $advanced = $params->get('sef_advanced_link', 1);

 and Replace line 426 with
 ->where($db->quoteName(‘alias’) . ‘ = ‘ . $db->quote($segment)); 

Well, first of all, line 426 is already like that in the original. Second, this does not do the trick. It do works with:

http://www.example.com/en/bigcatiii/intercatA/articlex.html

But it breaks wit a 404 error if you browse to:

http://www.example.com/en/bigcatiii/intercatA.html

Also, I noticed that the ID numbers are different. While the whole URL is

http://www.example.com/en/bigcatiii/666-intercatA/articlex.html

The same category description page is

http://www.example.com/en/bigcatiii/333-intercatA.html

There is also another solution that sound better, but also do not work, based on .htaccess

RewriteEngine on
RewriteBase /
RewriteRule (d+)-([^/]*) $2 [R=301,L]

The URLs appear ok, but the pages are not found. It would be so much better if we can provide a solution using .htaccess instead of changing Joomla core.

Still, changing the Joomla core would just fine, if this other googled suggestion was valid.

 Copy “components/com_content/router.php” to “/templates/your-template/html”

Meaning that once you moved router.php to your "local", you wouldn't need to redo all the stuff after an upgrade. (Unless, of course, router.php is updated, in case you would better mirror it again.)

Thanks for your time to solve this puzzle!

References

1- Change/ Remove Article ID in URL?

2- Removing the Article ID number

3- How to remove article id in url?

4- Remove article id from url for joomla 3.0

5- Enabling SEF

6- Remove article id from joomla 3 URL

7- Remove article id from joomla 3 URL

8- .htaccess redirect rule

9- Test .htaccess


Edited (2016/May/02): NEW Bounty for Joomla last version 3.5

3 Answer