Seek Engine Friendly Urls – Joomla! Documentation

Posted on

Search engine pleasant (SEF), human-readable or smooth URLs are URLs that make experience to both people and search engines due to the fact they give an explanation for the direction to the unique page they factor to. Since version 1.5, Joomla! is able to developing and parsing URLs in any layout, including SEF URLs. This does no longer depend upon URL rewriting completed by means of the internet server, so it really works even if Joomla! runs a server other than Apache with the mod_rewrite module. The SEF URLs follow a sure fixed pattern, however the user can define a brief descriptive text (alias) for each segment of the URL.

Internally, the nearby part of a SEF URL (the part after the area call) is known as a path. Creating and processing SEF URLs is consequently referred to as routing, and the applicable code is known as a router.

A suitable instance of routing is the URL to “Welcome to Joomla!” article inside the sample information.

  • Without SEF URLs became on, the URL is http://www.example.com/index.php?choice=com_content&view=article&identification=1:welcome-to-joomla&catid=1:modern-news&Itemid=50
  • With SEF URLs on and mod_rewrite off, it is http://www.example.com/index.php/the-­news/1-­trendy­-news/1­-welcome­-to­-joomla
  • With each SEF URLs and mod_rewrite on, it is http://www.example.com/the-­news/1­-ultra-modern-­information/1-­welcome-­to­-joomla

Search engine pleasant URLs may be activated by using turning on the Search Engine Friendly URLs option inside the Global Configuration. This alternative is on by way of default considering the fact that Joomla! 1.6. See Enabling Search Engine Friendly (SEF) URLs for more statistics.

FAQs

What do the numbers inside the URL mean?

By comparing the old and the new URL we are able to see numbers within the old URL,

http://www.example.com/index.php?choice=com_content&view=article&id=1:welcome-to-joomla&catid=1:latest-information&Itemid=50

however also in the new URL:

http://www.instance.com/the-­news/1­-contemporary-­news/1-­welcome-­to­-joomla

These numbers are the parameters that are wanted by using Joomla! to get the internal URL and display the web page you need to see. (In this situation, the primary numeral one is the ID of the class, the second one numeral one is the ID of the article.)

There is no index.Hypertext Preprocessor inside the URL anymore. Can I delete the file now?

No! The URL would not include the index.personal home page anymore, but internally the mod_rewrite will most effective redirect to the original route with out showing it to you.

What is the Alias value? And how does it get created?

Alias is listed below the Title subject in Articles, Categories, Sections and Menu Items. Joomla! can robotically create the alias for you. An automatic alias starts offevolved with the identify. All higher case letters are modified to lower case. Spaces and unique characters no longer allowed in a URL; they’re changed to dashes.

I need to specify my very own fee for Alias.

If you do no longer just like the alias provided by way of Joomla!, you can enter a cost of your choosing into that field. Many agree with using top key phrases to your URL allows seo. You can do so via inclusive of those key phrases for your identify, and allowing Joomla! to create the alias, or with the aid of growing the alias your self.

How is Alias utilized in a URL?

For a menu object, Joomla! uses the alias as the URL slug. Assume which you use the primary SEF URL alternatives and also you create a menu object called Products. Your URL would be instance.com/products.

Joomla! additionally uses the primary key values of information inside the URL to help the router navigate to the right web page. Continuing with the previous example, if your products menu item became for an Article­/Category Blog, the link for the Article Title and/or Read More link might have 3 elements:

  • The menu object URL – instance.com/merchandise;
  • Plus, the primary key for the Category and the Category alias – 32-fruit;
  • Plus, the number one key for the Article and the Article alias – 1-apple;

The complete URL is: http://instance.com/merchandise/32-fruit/1-apple

How can I put off the numbers within the SEF URLs?

The numbers within the SEF URL are wanted through Joomla!’s router to recognize how to direct web page site visitors. Once the router logic stabilizes, easy 0.33 birthday celebration system plugins can be evolved to reinforce the router talents by way of permitting greater desire. At that time, numbers will possibly be eliminated from the URL.

Route Formats and the Routing Mechanism

This phase describes Joomla!’s core (built-in) routing mechanism. Routing extensions may also trade the way routes are created for your machine.

Route Formats

To describe the Joomla! routing mechanism in more detail, we first need to pin down what we check with as a direction. Suppose that Joomla! has been established in http://instance.com/web sites/first/. The set up path is commonly called the base URL. A feasible example URL is http://example.com/web sites/first/products/32-fruit/1-apple. The first part of this URL is the aforementioned base URL, and neither Joomla! nor any element router can create URLs with a specific first component. The 2nd part, merchandise/32-fruit/1-apple, is a direction, consisting of 3 phases.

The first segment of a course is, for ordinary URLs, the alias of a menu item. The SEF URL is said to be routed via that menu object. The other segments are decided completely by using the router of the element that provides the sort of the menu object. The Category – Blog menu item type, as an instance, is provided by the Content issue, and therefore that aspect’s router is liable for constructing and parsing the ultimate segments.

It is likewise viable (for extensions) to invite the device to create a direction with out presenting a menu item to direction thru. In that case, the gadget will generally decide to create a special route that has the phrase aspect because the first phase. These routes are created the usage of a hard and fast format: the call of the issue (with out the main com_) is chosen as the second section and any parameters as the other segments.

Limitations

It is critical to notice developing a menu item is the handiest manner for a Joomla! consumer to define a course that ends in a particular aspect. It is, however, feasible to create a direction without showing it at the web page (in a menu). An frequently-carried out approach is to create a menu item in a menu that is not displayed everywhere. Such a menu is commonly called a hidden menu.

The preceding paragraph implies that it is not viable to make one thing liable for dealing with all routes. For instance, it is not possible to specify that the URL http://instance.com/thealias must show the Content object with the alias thealias, in which thealias may be any phrase. If this desires to be executed for a small range of articles, menu objects may be created manually for those. Else a routing extension is necessary.

This routing mechanism is therefore no longer as flexible as customers once in a while require. On the other hand, it has one massive advantage: it reduces the threat of ambiguous routes (routes that could cause exclusive pages). Since the primary phase of a path is always a menu item alias, the machine at once knows which aspect’s router ought to be used to parse it.

Implementation Details

Handling Routes

This phase describes the routing implementation. If you’re a thing developer, see Supporting SEF URLs for your factor.

Joomla routes are created and resolved by means of the JRouter magnificence. This class appears inside the component root of the currently energetic issue (special inside the alternative parameter in the query string) and consists of the router.Hypertext Preprocessor file in that issue’s root listing. It then calls one in every of two capabilities: one for creating the SEF URL and one for decoding the SEF URL.

The JRouter class is overridden via the Joomla CMS in /includes/router.Hypertext Preprocessor. In this document the build and parse features are overridden to nicely construct and parse the URLs for the Joomla CMS.

The router.php record in every aspect (as an example, /additives/com_content/router.php) need to contain the following two features:

  • ContentBuildRoute – this builds the SEF URL

    • Parameters

      • $question – that is a named array containing the querystring variables
    • Returns: an array of segments wherein each segment is separated by using a ‘/’ whilst later mixed to create the actual URL (the gadgets inside the array have to now not incorporate ‘/’ characters)
  • ContentParseRoute – this interprets an SEF URL

    • Parameters

      • $segments – that is an array that consists of the segments of the URL asked.
    • Returns: a name => cost array of the querystring variables that the hyperlink maps to

The SEF Plugin

The Joomla System – SEF plugin inherits JPlugin and implements the onAfterRender() function. In this feature the frame of the reaction so that it will be despatched to the browser is retrieved using JResponse::getBody(). The body of the reaction is then searched for links containing /index.personal home page… and replaces them with a accurate SEF URL by using calling JRoute::_(url).

JRoute builds SEF URLs by using instantiating a JRouter item and soliciting for that it build the proper link from the handed in URL.

Handling SEF URLs

By default the SEF URLs are dealt with through the JRouterSite object (from /includes/router.personal home page) and is known as with the aid of a name to JApplication::route() in index.Hypertext Preprocessor. This call is made at the $app variable that is definitely an instance of JSite (from /consists of/utility.Hypertext Preprocessor).

JApplication::direction() has a non-adverse end result on the $_GET array. That is, JApplication::course() units variables in $_GET via calling JRequest::set() with the overwrite flag set to false. Thus if a variable name is back from JRouter::course() this is already in $_GET, it’s going to not positioned that price into $_GET. This permits for custom routing.

Custom Routing

Joomla lets in you to create your own routing mechanism. In order to create this mechanism you ought to have a plugin that overrides the JPlugin::onAfterInitialise() feature. This function then parses the URL and creates the needed variables in $_GET earlier than the usual Joomla routing is carried out.

See Creating a System Plugin to reinforce JRouter for an example.

Leave a Reply

Your email address will not be published. Required fields are marked *