There is a new option in Joomla 3.8.2 allowing to get rid of ID in URLs (thanks to Ian who discovered it). If you have an older Joomla version and unable to update to 3.8.2 or higher follow the steps provided below:
Open components\com_content\router.php in an editor and make a small changes:
in function ContentBuildRoute(&$query) replace line 27
$advanced = $params->get('sef_advanced_link', 0);
with
$advanced = $params->get('sef_advanced_link', 1);
in function ContentParseRoute($segments) replace line 208
$advanced = $params->get('sef_advanced_link', 0);
with
$advanced = $params->get('sef_advanced_link', 1);
Comment out lines 228-232
if (strpos($segments[0], ':') === false) { $vars['view'] = 'article'; $vars['id'] = (int)$segments[0]; return $vars; }
so it would be
/* if (strpos($segments[0], ':') === false) { $vars['view'] = 'article'; $vars['id'] = (int)$segments[0]; return $vars; }*/
That is all. I tested this on my Joomla 2.5.4 test site and looks like it works, but I cannot say that it works in all the cases.
Some explanation
If you tried the method described above and it works for you, you could leave it as it is and close this page, but if you interested in some explanation please read below.
As seen from lines 27 and 208 Joomla Content Component uses ‘sef_advanced_link’ parameter, so setting this parameter to ‘1’ eliminates the need for changing this lines. It could be done by adding the following XML to ‘fieldset’ section of administrator\components\com_content\config.xml:
<field name="sef_advanced_link" type="radio" default="0" label="Sef Advanced Mode" description="Remove ItemID from Content URL?"> <option value="0">JNO</option> <option value="1">JYES</option> </field>
and then setting ‘Sef Advanced Mode’ to Yes in ‘Article Manager Options’ window:
Please note that setting default=”1″ in XML does not take an effect for some reason.
What concerns lines 228-232, if I leave them uncommented, ID disappears from URL and single articles open fine but when I trying to open a category not linked to some menu item I get “404 – Article not found” error message. I cannot say for sure, but I think that Joomla developers added ‘sef_advanced_link’ parameter but didn’t tested it well enough, so, probably, they will fix this code in future releases.
Very nice… new blank install 2.5.4 fixes issue. Anyone understand why joomla put this in the router.php file, what’s the purpose? http://docs.joomla.org/Supporting_SEF_URLs_in_your_component
Not clear to me what you mean, but I added ‘some explanation’, probably it would be helpful.
ALso works fine for me, Joomla! 2.5.8 – Thank you! Installed in functional but not yet live site.
But: in order to keep my core code pristine, I would prefer to use this fix in a standard override – but when the “fixed” router.php is placed in this folder:
/templates/mytemplate/html/com_content/router.php
it does not work. It ought to, as any component file can be overridden, AFAIK.
Ideas?
TIA for your help!
Thanks the trick
This is not working for joomla version 3.7
Yes works for me too 2.5.4
Great tip, thank you very much !
excelent. Perfectly work on joomla 2.5.4. Thank you for the tip
Works perfect on joomla 2.5.5 and 1.7.3
thanks!!!!!!!
Since the time that i searched this tip, thanks a lot !
Worked great for me on my landscaping site!
Works perfect , quick and easy , thanks for this great article
solved my problem – thanks
worked great thanks – but be careful doing this to a live site as any old links will no longer work i think
also updating joomla would probably mess this up however works great if you dont want an SEF extension installed (which would do the same if you wanted without code changes)
On a live site you could use redirect 301. Some example that I did with Apache 2 using .htaccess file:
RewriteRule ^recipes/(\d+)-([\-a-zA-Z0-9_]+)/(\d+)-([\-a-zA-Z0-9_]+)/?$ recipes/$2/$4/ [NC,R=301,L]
where “recipes” is the alias of some menu item associated with category view.
I wouldn’t suggest redirecting a dead link, because then Google and other search engines think that the link isn’t broken, so they’ll process that and the working link. And double content = bad rating. At least that’s what I heard. Just submit a new sitemap with the working links. You can also make an error page with a link back to your homepage.
Hello, Jim!
I do not know for sure, probably you are right, but I think that Google should not treat 301-redirects as double content.
I WOULD KISS YOU IF I COULD ( Figuratively Speaking )!!!!!!!! It is because of people like you that make the internet such a beautiful place! This worked perfectly for exactly what I needed.
Thank you!
You’re a true Joomla gangster.
Confirmed working on Joomla 3.0 as well
perfect…Many thanks from me..
doesnt work on 2.5.6 🙁
I did not tried it on Joomla 2.6 yet. What happening?
Does anyone have a solution for Joomla 2.5.6?
Works for me.. maybe you have shown article that not linked on menu. that’s why it causes error 404
This works on J2.6, but only partially.
If you type the article link without the id – it works fine.
If you type the article link with the id – it also works.
But all the links pointing to the article, for instance from latest news, category layout, search, from the article itself (if title is link) – all have the id in them.
You helped me alot. Everything working good on J. 2.5.6
Thanks!
Does any of Joomla developers reads this tips…
Wow, so much trouble for a small but important detail…
yes..its works perfect
Thank you buddy!
Thanks dude, worked perfect on J 2.5.4
Thank you very much.
I test this solution in Joomla 2.5.7 and is work just fine ! Thanks !
It works alright, next problem, is the fact that joomla won’t, reconize the HTML override file in template/HTML/com_content/router.php file, and for it to work, you have to override the original file.. Making it “dangerous” to update..
I think, the only solution is to change router.php manually each time you upgrade Joomla. Certainly, it is some kind of a problem.
thank you this works in 2.5.7 and solves a dilema of creating a lame menu item everytime.
Very helpful. Works nice on my site.
Works very good, Thank you!
Thanks for this tutorial
Excelente.! lo he probado en mi web de prueba (versión J2.5) y funciona de maravilla. Actualmente estoy en J1.5 pero ya voy cambiando. Elimina los ID de la URL perfectamente… GRAN APORTE.!!
Great tip, i’ve been googling for this. We are “Keep-It-Simple” Joomla Solutions provider and prefer not not use 3rd party extensions unless necessary. We only needed to kill item id’s – otherwise Joomla native SEF works fine for most projects.
Thanks again for the insight and sharing
-LDD
Great Tutorial! works on Joomla 2.5.8. http://linuxdatum.info/tutorials
i’m getting a 404-error… something about the parent category 🙁
would like to avoid using a 3rd-party SEF component/plugin just to remove the ID# from articles and categories in URL, but may have no choice. hopefully MijoSEF won’t slow me down too much.
Hi Admin,
Great tutorial! works like a charm on my Linux Tutorial Website: http://www.linuxdatum.info/tutorials
More Power! and Thank You!
Lo he probado en mi versión, aún demo (version Joomla 2.5.8) y funciona de maravilla… tremendo aporte a la comunidad 🙂
Hi. I just tested it in Joomla Joomla! 3.0.2 Stable and it looks like working perfect: http://outleofertas.com/ I don’t see any bug in my test site.
Hola. He hecho un test de esta solución en Joomla 3.0.2 y creo que funciona perfectamente: http://outleofertas.com/ No veo ningún bug en mi site de test.
This works very nicely!
Thank you for the awesome tutorial.
I was tired of the SEF components that mess the whole site up, this is a very easy and clean method to simplify the URLs.
Hi,
I tested the method on my Joomla 3.0 site. It’s good but it seems only to work if there’s a hyphen in the article alias, and I can still access the same page if I type it with article id on the address bar.
For example, mysite.com/category-alias/132-article-alias and mysite.com/category-alias/article-alias both work
Another interesting thing that happens with this method is you can have endless article aliases in the url.
So, if you have an article with the alias “article-1,” this url:
mysite.com/category-1/article-1
and this one:
mysite.com/category-1/article-1/article-1/article-1/article-1/article-1
will redirect to the same page.
I do not know for sure, but probably content component router initially works in this way.
SIMPLY PERFECT! THANK YOU VERY VERY VERY MUCH!!!! =D
these spells act on Joomla 3.0.2. both links “/ID-nameofarticle” and “/nameofarticle” will get you to the same article…
but in the tile of blog articles link remain with ID.
still thanks 🙂
thank you very much. it help me alot
thank youuuuuuu very much.
Thank you very much, still working !
Thanks for share. Work great !!!
Thank you ! Works on Joomla 2.5.9 !
Should I be worried about future Joomla updates ?
You need to apply this changes each time you update Joomla.
Excelente tutorial, funciona en Joomla 2.5.9.
Gracias…
Hi. I think this workaround is no longer valid in Joomla 3.1 beta 3. I’m trying to do it and the code
if (strpos($segments[0], ‘:’) === false) {
$vars[‘view’] = ‘article’;
$vars[‘id’] = (int)$segments[0];
return $vars;
}
is different. Can someone check it?
Thanks. Jorge M
Sorry, my bad, i was doing a mistake, It’s working in Joomla 3.1 beta 3.
Thank youuuuuuuu!!!!!!!!
Not work of my site pleace help me 🙁
Thanks
Hi.
I just updated my site to joomla 2.5.11 and the workaroung is no longer working. What can I before google start getting the change in the urlS?
Thanks
Hi! check the content of components\com_content\router.php probably this update overwritten your changes
Hello dmitriano with the Sef urls that we want to solve otherwise specifically about the htaccess should go. send me an email if you would like to join
Thanks Dmitriano, it’s working now in joomla 2.5.10.
I’m doing testing and i cannot make it work in joomla 3.11 despite it worked in joomla 3.1 beta.
Can someone do another testo to verify? Thanks
Many Thx, i have tested it on joomla 2.5.11 and it rocks !
Jorge, I cannot get this to work on 3.1.1 either. If anyone knows of a fresh workaround, please share!
for me its working that means not showing the id number but one error comeing when i clicking the given url the error is ” 404 Article not found “. why this error coming in my Joomla3.1.1.how to solve this error
Thanks for your article. I tried this on Joomla 3.1.1. ID gets removed from URL but it results into 404 error. Any suggestion?
Thanks, working on joomla 2.5.11
Hi, this doesn’t work for me on Joomla 3.1
I tried both, template override and editing the core router file in com_content.
Anyone got this working in J!3.1?
Modifying the router.php file works fine in 3.1 – buit – using a standard template override apparently does not work. Make sure both your browser and Joomla! caches have been cleared. I see no reason why a standard template override should not work…
Great article, very easy to do
Its NOT working for me, I have 2.5.11
I’ve followed the instructions above but I still have a number in my web link menu?
Please help !
Strange… It works for me on Joomla 2.5.11.
Hi
It doesn’t seem to work for joomla 2.5.8.
Thanks
Hi! Two people said that it works for joomla 2.5.8. See comments above.
Attention:
this solution causes, that every article is reachable by 2 URLS, so it produces duplicate content, which is a no go.
without id: http://www.yourdomain.com/yourcategory/your-article
with id: http://www.yourdomain.com/yourcategory/id-your-article
It is not a problem at all. Use 301 redirect. You could add the following to .htaccess (if you are using Apache)
RewriteRule ^yourcategory/(\d+)-([\-a-zA-Z0-9_]+)/(\d+)-([\-a-zA-Z0-9_]+)/?$ yourcategory/$2/$4/ [NC,R=301,L]
The router hack works, but the URLs which have already been indexed by Google are still showing with numbers.
Tried this extra rewrite rule, but still shows the numbered articles.
http://nowcosmetic.co.uk/botulinum-toxin/14-pouting-and-smoking-causes-wrinkles
Works in Joomla 2.5.11 as well. Great article. I paraphrased with a link back to this article in our developer news area of ajadmin.com. I hope you do not mind.
Does anyone know how to get this to work in 3.1?
Doing the above breaks Joomla – the URLs generated do indeed lack the IDs for categories and articles, but Joomla can’t actually find the article/category without the IDs:
#404 COM_CONTENT_ERROR_PARENT_CATEGORY_NOT_FOUND
Thanks,
Steve
Hi Steven,
I get the same error after modifying router.php, could you solve it?
I tried adding a parent category, but no luck,
thanks for your help.
Kind Regards,
Its not working in joomla 3.1
plz provide the solution
thanks..
Brilliant!!! It works great
After updating the version 2.5.11 to version 2.5.13 appeared articles IDs in the URL, big problem for Google indexing URLs since they are different and I had to redirect them all to appear Article ID in the URL . But with this brilliant explanation the problem was solved and now the URLs are as before the upgrade.
::: Thank You ::: Best Regards :::
I tested in Joomla 2.5.11. It works.
and now I don’t need sh404sef component.
Thanks so much.
Thanks a ton. Worked out well. I am using 2.5.11. Really appreciate this article. 🙂
Works in Joomla 2.5.11! Thank you!
It works in Joomla 2.5.14 but with the following error – “Notice: Undefined index: id in C:\wamp\www\components\com_content\router.php on line 282”. I could suppress error reporting in my localhost but what about in my live site? Anybody knows of the probable future impact of this error in live site? Thanks!!
It works for joomla 2.5.14 .. Many many thanks!!!!
How it works for Joomla 3.1.5?
Hello, Markus!
This method works only for Joomla 2.5-3.0. It does not work for Joomla 3.1 and higher. I wonder if someone have ideas about Joomla 3.1.
It works for 2.5.14..! Thanks A lot dmitriano !!
Great! very good on Joomla! 2.5.14
The Sef Advance mode option doesn’t appear here. Using Joomla! 2.5.14
I have tried this little hack before on older Joomla! versions, and it worked like a charm! Any ideas as to why it doesn’t do anything for me now?
Thank you!
Best, Astrid
Great! very good on Joomla! 2.5.14
Yes, works all right in 2.5. Thanks for this.
Hi Developers.
Very for this solution, But there is one issue while creating category blog, it shows only a blank page.
What I think is, this perfectly linking single article in a menu, While making a category blog. OOps
Thanks for the post, dmitriano.
I’ve wrote a blog post with other solution which don’t need to make a core-hacking. Please take a look at Remove Joomla 3 Tags ID in the URL
Thong Tran
This solution worked till now. But with the last update (2.5.17)no longer works.
Hi all,
I have placed the “router.php” file in:
/templates/MY-TEMPLATE/html/com_content/router.php and not working.
Appear always the ID of the article.
Solution?
Thanks
Not working into joomla3.1
Thank you very much! Great and simple article. Working with Joomla 2.5.16.
It works for me on Joomla 3 but when i click the title, it will show 404 Pages
Thanks you verry much!!!!!!!!
A article useful to everyonce.
I love you!
I tested on my website which is online, already published, and now articles are 404.
Please help.
with version is Joomla! 3.2.1.
all articles who linked with a menu are working fine, only articles in Category Blog showing 404 error.
I have already made on .htacces file.
Any idea?
the article alias must be a minimum of two words! 😉
Hi,
Thanks for this wonderful post. I tried in J3.2.3 and getting 404 page. Any other workaround available for this.
I also tried in joomla 3.2.3
it works for some pages, but not all.
It is strange
It seems to be working fine in Joomla 2.5.19. It didn’t seem like it at first, but I checked it out and it looks fine.
tried to find support from Joomla forum, other forums as well as googled to fix the article ID number in each URL in Joomla, yet I still could not fix
Man, I’ve got Joomla 3, and can’t figure it out. I don’t know why they do it. It just doesn’t make sense!
It is not working for me after updating to Joomla 2.5.20
I redid router.php after the update, but nope. Not working 🙁
At the Joomla 3.3 doesnt work. The explanation (i think) is because at the config.xml file, the sef configuration doesnt exist anymore.
Without an extension, the only way to remove the article id is to create a menu item leading to the article. Once you have done this, the id will disappear, and will also get rid of the leading category URL.
Example before: http://www.yourdomain.com/category/12-cool-post
Example before: http://www.yourdomain.com/cool-post
IMO this is much better for seo, unless you need the subcategories displayed
Wonderfull works great in all my websites
This can’t seem to be working on Joomla 3.24. Please advise.
Work on Joomla 3.3.6 just by changing sef_advanced_link value from 0 to 1. But just as the others, both with-id and without-id links are accessible.
working: http://theasialover.com/s4-mungkin
working: http://theasialover.com/14-s4-mungkin
Work on ‘Category Blog’ and ‘Category List’ too. But didn’t work on Tags and ‘List of tags’ (not 404 error though, just “No matching items were found.”)
working: http://theasialover.com/artistlist/12-kim-hyuna
NOT working: http://theasialover.com/artistlist/kim-hyuna
Have you test by creating menu of “artistlist”?
thanks
I just upgraded to 3.3.6 and it still works. You have to clear your cache.
Hello, I can’t do it right because when I treminated to put these codes above I can see the Sef Advanced Mode im my cpanel
Please someone can help me friendly?
Take a look of this link http://www.vozhaitiana.com/component/k2/97-social/comment-pardonner so I want to see it like http://www.vozhaitiana.com/social/comment-pardonner . Please help me my friends. It’ 3 am in my country so I can’t sleep because I want to resolve it.
not working at joomla 3.2.3
Hi,
i’d like to thank a lot for this post.
It fixed my issue!!!
I use joomla 2.5.28 and it works fine!
Very, very thanks
Best regards
To be frank, I cannot understand what you say partially. I’m looking for an easy way to remove the article ID of Joomla article. I’m searching on the web and have found https://besthostingforjoomla.com/remove-article-id-in-joomla/, telling me how to do this using code. However, I want something easier. Is there any suggestion?
@Susan
1.) You might create single Article MenuItems… either in a hidden or visible menu. Most applicable on sites with less items… but you might also streamline this tedious process with an extension:
Auto-Menus with Kazaam! http://extensions.joomla.org/extension/kazaam
Or something like Add-to-menu http://extensions.joomla.org/extensions/extension/administration/admin-navigation/add-to-menu
2.) Try a 3rd-Party SEF extension:
Either a bigger solution if you need more features and options. i.e. sh404SEF, MijoSEF, and others…
Or a specific solution like “Direct Alias” by AlterBrains. Available in free and pro version. http://extensions.joomla.org/extensions/extension/site-management/sef/direct-alias
Good luck!
You’re a true Joomla gangster.
I have used your trick to hide ID’s from URL.It works fine when I choose “Category List” to display in non-display menu.But when I used to “Single Article” in menu,it redirects to 404 page and error display is:
404 – COM_CONTENT_ERROR_PARENT_CATEGORY_NOT_FOUND
Please help me with this problem.
Thanks in advance.
Not working for me. Not sure if i am missing something. I have got Joomla! 2.5.14 and also AceSEF plugin installed. Please let me know if it affects the SEO friendly structure of URLs
Just updated to 3.4.4 and seems to be working fine.
I use Joomla! 3.4.8 Stable and the hack of dmitriano works fine for me.
Thanks to dmitriano
by Richard from Knot Together
Thank you. It’s Work!
I have been using this hack for years but just found that it only work if the Alias are more than one word. For example, if the URL is http://www.site.com/menu-alias/a you’ll get an 404, but if you use http://www.site.com/menu-alias/a-a it will work. This only applies to Articles alias, not menus.
I should have added that is dose no applies to tags URL as well.
Did you find a solution for one-word alias ?
Not funf in joomla 3.5.1
Now it’s funf!!!
Create the file config.xml, add this code above and upload to administrator\components\com_content
JNO
JYES
Thank you very much, still working !
Thank you very much, you resolved my problem. 🙂
It’s still needed and still works on 3.6.
Still not work on Joomla 3.6.2. Help!
Joomla 3.5
From : (line 34)
// Get a menu item based on Itemid or currently active
$params = JComponentHelper::getParams(‘com_content’);
$advanced = $params->get(‘sef_advanced_link’, 0);
To:
// Get a menu item based on Itemid or currently active
$params = JComponentHelper::getParams(‘com_content’);
$advanced = $params->get(‘sef_advanced_link’, 1);
From: (line 294)
// Get the active menu item.
$item = $this->menu->getActive();
$params = JComponentHelper::getParams(‘com_content’);
$advanced = $params->get(‘sef_advanced_link’, 0);
$db = JFactory::getDbo();
To:
// Get the active menu item.
$item = $this->menu->getActive();
$params = JComponentHelper::getParams(‘com_content’);
$advanced = $params->get(‘sef_advanced_link’, 1);
$db = JFactory::getDbo();
From: (line 451)
->where($db->quoteName(‘alias’) . ‘ = ‘ . $db->quote($db->quote($segment)));
To:
->where($db->quoteName(‘alias’) . ‘ = ‘ . $db->quote($segment));
Just updated to 3.6 and seems to be working fine.
This is working for J3.6.2 articles & categories. But not for tags. I am getting 404 error for Tags. Any help with Joomla Tag URLs.
I think this is very bad for SEO purpose (and i think remove the ID is mostly for SEO purpose)
For new Joomla 3.7 working?
Here’s the answer ppl.
One of my students pointed me to this forum thread page, as she searched the answer- then came and asked me for help.
Do this:
You go to the administrator/components/com_content/config.xml file, and paste the following code:
JYES
JNO
Save the file.
THEN:
Log to your joomla, and go to Global Configuration. Down the left side is a sidebar which has a bit of a heading “Component”. Look for “Articles”.
Select it.
You’ll see tabs in the upper area of the window. The second last tab from the right is “Integration”.
Select it.
When the content appears- the final ‘item’ will say ‘Sef Advanced Mode’. This freedom of choice! was created by pasting the code into the config.xml file.
Select “Yes”, click the “save” button- and your Blog IDs are gone. It’s likely that this item could require attention, when you next upgrade Joomla- and the solution might not work on future versions.
Reach out through my website- and I’ll provide an answer.
cheers
Pete Lorocco
very useful tip for me this is awesome
It works in Joomla 3.8 ! Great job.
I just updated to Joomla 3.8.2 and this looks different. The file router.php does not include the same info as above. IDK if I am missing something but this file appears to have changed and this doesn’t work.
It did work for me before but not now. “sef_advanced_link” is gone. Now there is “sef_advanced” and it’s only mentioned once in the file not twice like the old.
I couldn’t find the lines:
if (strpos($segments[0], ‘:’) === false) {
$vars[‘view’] = ‘article’;
$vars[‘id’] = (int)$segments[0];
return $vars;
}
O.k. I found a SOLUTION:)! Yay Joomla!
Follow:
go to articles>options>integration>url routing>modern>remove id’s from url’s>yes
Clear caches and voila it’s gone. no more editing this file.