Displaying items by tag: redirection

Friday, 25 October 2013 00:00

Redirection rule features

As mentioned earlier the "From URL" field can contain a regular expression and can match the whole URL or just a part of it. The following table shows some regexp examples.

"From URL" fieldWhat does it mean
/section/*$ The dollar ($) means "end with". The star (*) means "match zero or more occurrences of previous character", that is the slash (/). So this rule means "address ends with /section or /section/".
^/section/9-article\.html$ The caret (^) means "start with". The dollar ($) means "end with". So the rule means "address starts and ends exactly with /section/9-article.html".
^/section/11-articles\.php\?id=12$ The caret (^) means "start with". The dollar ($) means "end with". Also, we need a "literal" question-mark (?) for inline arguments, so it must be escaped with a backslash (\?). So the rule means "address starts and ends exactly with /section/11-articles.php?id=12". Note that any special char needs to be escaped with a backslash to be literal, so we should escape also the dot (.) char. If not escaped, the dot will match with "any char".

The rules ordering is important for matching the source URL. For each URL request, all published rules are compared according to their ordering. Even if two or more rules match, ONLY THE FIRST ONE in the rule ordering will be used. This can be useful, as example, to distinguish a category from its articles. If we have two URLs as follow:


Rules could be configured with the following "From URL" field:

Item OrderWrong OrderCorrect Order
5 /category/ /category/article-1.html
6 /category/article-1.html /category/


For http://www.mysite.com/category/article-1.html both rules match this URL, but only the first matching rule is applied so, if rules are configured in the wrong order, the redirect for page article-1.html will never be used.

Internal Redirect

This feature is available only in the Enterprise version of ReDJ. The 301 (Moved Permanently) or 307 (Temporary Redirect) redirects are client-side redirects. The user from his web browser requests a page (the source URL), and the web server responds with the address to which the page was moved (the destination URL). At this point, it is the client browser that makes a new request for the new address (i.e. is the client that performs the redirect).
With the "Internal Redirect" instead, is the web server that changes the page returned to web browser with the new destination. The result is a server-side redirect (i.e. the redirect happens "internally" to Joomla), and the user does not notice any URL change in the address bar. This is a great solution to create URL aliases and short URLs. Just as example, let's consider an existing URL like the following:


It is possible to create a rule with a redirection type 200 (Internal) that match to the following URL:


The page content sent to client is exactly the same for both URLs, but the shortest URL is much friendly and better for SEF and SEO.

Dynamic Destinations (Macros and Placeholders)

Let's take a deeper look at "To URL" destination field. Since version 1.5 of ReDJ, a support for complex "macros" has been added, and this allows to create dynamic destinations. The version 1.7.1 introduces support for "placeholders", that adds a new dimension to build complex URL transformations.

When the URL request matches the "From URL" source field of a rule, if the destination field "To URL" contains one or more macros or placeholders, then ReDJ first calculates and replaces any placeholder and macro with its current value, builds the final "real destination" URL, and finally performs the redirect.

Macros allow, as example, to manipulate pieces of the current matching URL (e.g. a query variable), placeholders can define new variables using constant strings, macros and other (previous) placeholders, so both let you to create dynamic destinations as complex transformations of the current source URL.

Here a practical example of dynamic destinations and macro substitution:

Source URL http://www.yoursite.com/old/index.php?task=view&id=123&ItemId=3
ReDJ "To URL" http://{siteurl}/new.html{querybuild ItemId=12}
Destination URL http://www.yoursite.com/new.html?task=view&id=123&ItemId=12


Placeholders allow you to define a set of values where each value is associated and identified by a name. A placeholder can be used in the definition of other placeholders or in the definition of meta info (practically they are based on the same principle of the variables in programming languages). Syntax for defining a placeholder is name=value where 'name' is the placeholder identifier (placeholder valid name, like variables in PHP convention, starts with a letter or underscore, followed by any number of letters, numbers, or underscores), while 'value' can be any string, and can also contains macros or placeholders defined before, and both will be replaced with their current value. The syntax to use a placeholder is ${name}, where 'name' is the name of the placeholder. Each rule has a text area field to define any number of placeholders, one for each row. For example, if you enter:

b=${a} is
c=${b} an
d=${c} example

Putting the placeholder ${d} in a meta field (e.g. title or description), this field will assume the value 'this is an example'. Here is a practical example of how to use the placeholders to get a complex result through the use of available macros in a sequence of definitions. Let's assume we need to create a rule for URL:


We want to withdraw the article id (53), and perform a look-up on the database for getting the article alias (using-joomla), to be used for example in the page title. We can define the following placeholders:

id={preg_match 1}/option=com_content&view=article&id=([0-9]+)/i{/preg_match}
alias={tableselect #__content,alias,id}${id}{/tableselect}

After this, putting ${alias} in the title field, this will be replaced by 'using-joomla' in the page.

Published in ReDJ for Joomla 2.5
Friday, 19 July 2013 00:00


This documentation is updated to ReDJ version 1.7.8. Some described features are only available in the Enterprise version, not in the Community version.

ReDJ is a Joomla native extension that allows to efficiently manage URL redirection. This is very useful for creating URL aliases, and managing redirects from an old URL to a new one. A very similar extension has been added into Joomla since version 1.6, but ReDJ supports powerful regular expressions that allow to match more than one source URL. In this way it is possible to create a group of redirects with just one ReDJ rule.

ReDJ also supports usage of "macros" in the destination URL. A macro is like a function whose value is calculated at runtime (when the rule matches an URL). There are a loto of macros available and this allows to create dynamic destinations, with a different redirection for each source URL. To increase flexibilty in the building of dynamic destinations, also "placeholders" are supported. A placeholder is like a variable whose value can be assigned using text, macros or other placeholders, and can be used to build the destination.

Another great ReDJ feature is the configurable redirection type for each item, with support for 301 (Moved Permanently), 307 (Temporary Redirect) and also 200 (Internal Redirect) (available for Enterprise version only). With the Internal Redirect is now possible to create a "real" URL alias with Joomla.

Last but not least, there are many other features available, such custom error pages, error tracing, referer tracing and so on, that can dramatically improve your SEO ranking. We will describe each one in detail in the next part of this guide. In the following paragraphs we will also learn how to make better use of regular expressions, macros and placeholders to take full advantage from ReDJ.

How it works

ReDJ package includes a component for managing list of redirection rules, and a plugin that examines all the requests and redirect them to a different page when needed by an active rule. These are the main steps to start using ReDJ (for the impatient):

  1. Install the package using Joomla Administration interface;
  2. Enable the plugin "System - ReDJ" and set its ordering and other parameters;
  3. Use ReDJ component to manage redirects, errors and referers.

Detailed instructions on each step are described in the following paragraphs. In this section we just want to focus on some basic concepts related to ReDJ and how it works.

The first important thing to understand is the "rule" concept. With ReDJ Manager (the component interface) you can create as many items as you want, and each item is a redirection rule. But not necessarily an item corresponds to a single page (i.e. matches just a single URL).

A rule has a "From URL" field that can be full URI or just a part of it. For example, it can be "/home.html", then this rule matches both the URL http://www.mysite.com/home.html and http://www.mysite.com/orders/home.html?view=status. So, it means that with a single rule is possible to match multiple source URLs. But the content of the "From URL" field can be a regular expression, and this provide a powerful way to specify complex search patterns for matching URL. The "Skip" field is similar to From URL", it can be a part of URL and contains a regular expression, but it offers a way to skip the rule. When the skip condition matches the rule is discarded. In the next paragraphs will be shown many regular expression examples.

For any request on the site, the ReDJ plugin compares the requested URL with all the rules enabled in the ordering set for rules. The first matching rule found (if there's at least one) is used for redirect.

Published in ReDJ for Joomla 2.5
Wednesday, 26 October 2011 00:00


ReDJ is a native extension (component + plugin) available for Joomla that allow to manage URL redirections. This is very useful for creating URL aliases, and managing redirections from an old URL to a new one. A very similar extension has been added into Joomla since 1.6 version (Redirect component), but ReDJ supports powerful regular expressions that allow to match more than one source URL. In this way it is possible to create a group of redirections with just one ReDJ item. It's so easy.

Also, now ReDJ comes with support for macros into destination URL. This means that from now the destination URL can be dynamic.

Finally, an "internal redirect" feature has been added (Enterprise version only). With these features now is possible to create "real" URL alias with Joomla.

There are two versions of ReDJ, Community and Enterprise, both released under GPL license. The Community version is completely free, while the Enterprise version has a little subscription fee, but introduces some advanced features. Here's a comparison matrix between Community version and Enterprise version:


Features ReDJ Community ReDJ Enterprise
Intercept and redirect any error 404 URL Yes Yes
Support for 301 (Moved Permanently) Yes Yes
Support for 307 (Temporary Redirect) Yes Yes
Support for 200 (Internal Redirect) No Yes
Use of regular expressions to specify matching source URLs Yes Yes
Case-sensitive option on the matching source URLs Yes Yes
Request only option to match the full URL or just the REQUEST_URI part Yes Yes
Decode URL option to decode URLs before to check if match with rule Yes Yes
Support for skip rule condition Yes Yes
Support for skip usergroup condition No Yes
Support for placeholders Yes Yes
Option to apply a rule only in case of error Yes Yes
Possibility to add a note for each item Yes Yes
Use of macros to specify destination URL (dynamic destination URLs) Yes
(42 macros)
(54 macros)
Custom error page Yes Yes
Use of macros to customize error page Yes
(6 macros)
(6 macros)
Trace redirections with hits counter and info about last visit Yes Yes
Trace custom error page with hits counter and info about last visit Yes Yes
Trace errors with hits counter and info about last referer and time Yes Yes
Trace referers for each visited URL with hits counter and info about last visit Yes Yes
Configurable list of referers to exclude from trace with macro support Yes
(2 macros)
(2 macros)
Option to redirect any error 404 URL to a custom page Yes Yes
Option to shortcut extensions directly on the error page Yes Yes
Option to set a global base path (easy items portability) Yes Yes
License GPL 2.0 GPL 2.0
Price Free 9 €
  Download ReDJ Community Buy Subscription to ReDJ Enterprise
Published in Products