This page short URL: yq4

When to use advanced aliases

Advanced aliases should be used when, well, you have complicated redirects needs. If you only want to redirect a single page to another one, on the same site, you can use simple redirects instead, as described on the previous page.

Typically, you will use advanced aliases when:

  • you want to redirect many pages with one single redirect rule
  • redirect target is on another website
  • you don't really want a redirect, but instead a canonical link

Note that you can also mix those situations, ie: redirect multiple pages to multiple pages on another site.

How to create/manage advanced aliases

Advanced aliases are listed as usual under sh404SEF Aliases menu item. You can use the usal toolbar buttons to create an alias, modify it or delete it.

View of sh404SEF aliases list

You can also use drag-and-drop operations to re-order your aliases as you see fit. Use the standard Joomla! drag-and-drop handles on each line to move it to another location.

Clicking on an existing alias lets you modify it:

View of sh404SEF alias edition window

In the simplest form, as in the example above, enter:

  • the alias ("main-alias-1")
  • the redirect target in non-SEF form ("index.php?option=com_content&Itemid=497&id=49&lang=en&view=article")
  • select whether you want this alias to trigger a redirect, an internal rewrite or whether a canonical tag should be inserted in the original page.

Based on that example, whenever someone requests the https://www.example.com/main-alias-1 URL, they will be redirected (with a 301 code) to the address: https://www.example.com/extensions/templates/typography

Note that sh404SEF will of course turn the non-SEF URL you entered into a SEF one.

Aliases for multiple URLs

The example above redirected one single URL to another specific URL. Using special characters, called wildcards, you can create aliases for many URLs in one single rule. The special characters to use are:

{*}
{?}
  • {*}: will represent any number of any character
  • {?}: will represent any character, but just one

You can use wildcards in both the source and the target of an alias. For instance:

Creating an alias with wildcard characters

This will cause any URL that starts with "old-category" to be redirected to the same URL with "new-category" at the beginning, as in:

https://www.example.com/old-category/article-1 -> https://www.example.com/new-category/article-1

Please see below more common usage example.

Redirect vs canonical vs internal rewriting

sh404SEF can either trigger a redirect, insert a canonical link or preform an internal rewriting. This is done by selecting one option or the other when creating/editing the alias:

Selection of alias target type: canonical, redirect or rewriting

Redirect

This is the most common situation, to use whenever you have changed a URL and want visitors and search engines to be sent to the new address of a page. As in the example above, anyone visiting the source address will be sent to the target address. Sent means that the address in the address bar of the browser is changed, and user is really sent to the new page.

There are situations however when you want both the old and new address to still exists and be accessible, but you would like search engines to only take into account one of the multiple addresses. A common use case is e-commerce: imagine having one product that should be found in multiple categories. For proper navigation, each page should have its own URLs, but you want search engines to be informed that this is in fact the same product, and they should concentrate all SEO signals on only one of those pages (usually named "the canonical page").

Consider the example of a bicycle tail lamp sold by a shop. The lamp can be fitted to urban bicycles, but also to children bikes and all-roads bikes. So the tail lamp product page can actually be found in 4 locations:

  • shop/bikes/accessories/tail-lamp
  • shop/bikes/urban/accessories/tail-lamp
  • shop/bikes/children/accessories/tail-lamp
  • shop/bikes/all-roads/accessories/tail-lamp

It's all good for visitors, but we want that tail lamp product page to be indexed by search engines once, and we want them to use the shop/bikes/accessories/tail-lamp address. To achieve that, we must insert a rel=canonical tag in each of the additional pages, that designates shop/bikes/accessories/tail-lamp as the canonical URL.

This is where you can use sh404SEF canonical aliases: you still want all those 4 URLs to exists and be available to visitors, but group them together for SEO reasons.

Internal rewriting

Internal rewriting is a little bit different from the two previous options in that it is invisible. Internal rewriting is the fact of displaying the content of a given page instead of the the content of the original page.

Assume you have 2 articles with the following URLs:

https://www.example.com/article-1

and

https://www.example.com/article-2

In specific circumstances, it might be useful to display the content of article 2 when a request is made for article 1. This is what will happens if you create an alias such as:

Selection of alias target type: canonical, redirect or rewriting

After creating this alias, anyone requesting the page https://www.example.com/article-1 will see the content of article 2 BUT the URL will not change and stays as https://www.example.com/article-1

Note that in such case, both URLs will still work, ie article 2 content can be accessed from both https://www.example.com/article-1 and https://www.example.com/article-2.

Internal rewrite are only useful in very specific cases such as when integrating a 3rd-party script for an e-commerce, CRM or ERP system. They should normally not be used in the regular operation of a website.

External targets

You can use URLs on other websites to be the target of an alias, both for redirects or canonical type of aliases. When doing so, you must provide the full URL of the target, including the full domain:

Creating an alias with wildcard characters to another website

In this example, all URLs from the current site, starting with "old-category" will be redirected to an equivalent URL on another site, as in:

https://www.example.com/old-category/article-1 -> https://www.anothersite.com/new-category/article-1

Common use cases

Category name change

You need to redirect multiple pages at the same time. For instance, you changed the name of a category, and you want all /cars/[redacted]x URLs to be redirected to /vehicles/[redacted]x

Alias type: Do a 301 redirect
Alias:      cars/{*}
Target URL: vehicles/{*}

Will redirect /cars/ford-mustang-1965 to /vehicles/ford-mustang-1965

Site redirect

You want to redirect one or more URLs on your site to another site. For instance, redirects all https://blog.example.com/[redacted]x URLs to https://www.example.com/blog/[redacted] (assuming sh404SEF is running on the https://blog.example.com website).

Alias type: Do a 301 redirect
Alias:      {*}
Target URL: https://www.example.com/blog/{*}

Will redirect /seo/how-to-create-redirects to https://www.example.com/blog/seo/how-to-create-redirects

Change in URL structure

For instance, assume you have removed one category level, as in /vehicles/cars/[redacted]x to /cars/[redacted]x. This is achieved with:

Alias type: Do a 301 redirect
Alias:      vehicles/cars/{*}
Target URL: vehicles/{*}

Will redirect /vehicles/cars/ford-mustang-1965 to /vehicles/ford-mustang-1965.

Products appear in multiple categories

Assuming again that all our bicycle accessories can be found in multiple categories:

  • shop/bikes/accessories/tail-lamp
  • shop/bikes/urban/accessories/tail-lamp
  • shop/bikes/children/accessories/tail-lamp
  • shop/bikes/all-roads/accessories/tail-lamp

  • shop/bikes/accessories/front-lamp
  • shop/bikes/urban/accessories/front-lamp
  • shop/bikes/children/accessories/front-lamp
  • shop/bikes/all-roads/accessories/front-lamp

We want the URL from the top accessories category to be the "canonical" URL, the main one. We will achieve this with this alias definition:

Alias type: Insert canonical link
Alias:      shop/bikes/{*}/accessories/{*}
Target URL: shop/bikes/accessories/{*}

This will cause, for instance, the page shop/bikes/urban/accessories/tail-lamp to have a canonical link to the page shop/bikes/accessories/tail-lamp.

You can verify that your "Canonical" alias works fine by checking the HTML source code for your source page. It should have a rel=canonical tag inserted into the page.

Regular expressions

For even more complex situations, you can directly use regular expressions when setting up aliases. sh404SEF will interpret your alias as a regular expression if you start it with the ~ character:

Using a regular expression when creating an alias

If ~ is found as the first character of an alias, sh404SEF will simply use the alias a regular expression, without any kind of transformation. Please note that we will not provide support with respect to creating the regular expressions that you need for your specific purpose.

Please note the specific syntax for the target URL: instead of the usual $1, $2, ... place holders common when using regular expression, you must use {$1}, {$2},... This is because the $ sign is a valid URL character and so it's perfectly possible that $1 or $2 exist in a URL.