0

I want to know the purpose of routing the urls. Can anyone explain me why do we route urls?

  • Welcome to JSE. Please take the tour to familiarise yourself with this community and, ideally, read our help pages about how to ask a good question. Your question has been flagged as Low Quality by the system because of how short it is. If you have conducted research already (this is an expectation of question posters), please include in your question what you DO already understand so that volunteers don't bother to tell you what you already know. Making your question less broad makes your question more attractive to answer by volunteers who may have limited time to help here. – mickmackusa Nov 15 '19 at 11:23
  • The question is answered at tons of websites, but you have to simply think about a big and continually growing stadium with always added new seats where you have to sit every visitor with different (or same) tickets to their correct place. That is what the router does basically repeatedly in a dynamic web application, and that is why it was developed with dynamic web frameworks. It could be explained of course many many different ways... – Zollie Nov 15 '19 at 18:12
0

Hard to give a precise answer without more detail, so this will be oversimplified, perhaps too much so, but I'll try.

Joomla URLs natively look like someone dumped part of a can of alphabet soup on the screen. Joomla uses those numbers to find the content being requested, but why should a site visitor have to put up with such a jumble? And what is a search engine to make of that URL? (/sensible/human/readable/link as opposed to index.php?option=com_whizzbang&Id=23&morearcaneitems=toomany even makes more sense to a search engine trying to classify the page it's indexing.)

The routing system in Joomla provides a mechanism so that when that content item's name changes, or category, or pretty much anything else, the original link can still be used by the router to find the modified page. Without a routing system none of the items in the query string could ever change without having to change the URL. What if a visitor bookmarked a page? Or you emailed someone a link to your site. When you made that little change, that item got lost and none of those links work any more. With a routing system in place, Joomla can use it to figure out whether this received query string fits this modified page, instead of just giving your visitor a 404.

We use the routing system to output links for much the same reason; it's a quick and simple way to create a consistently-formatted URL that Joomla will be able to use to find the page again, and if the page changes, the call through the routing system will pick up the changes automatically, so every navigation link in the site will now use the current real URL.

It's a chunk of a larger practice known as "encapsulation" where you hide the details part of the system needs to know away from the other parts of the system that don't need to know them. That makes the code easier to maintain because if those hidden details change only that one part of the code needs to change.

In the case of the routing system, this hides the details of the Joomla internals from the rest of the world, giving you the ability to change them as you need without impacting the ability of the rest of the world to find your page. Without the router any time you decided to move an article to another menu or category, the query string would be different and anyone with the old query string couldn't get to the page.

Hope that helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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