Skip to content
Aron Griffis edited this page Aug 27, 2018 · 2 revisions

URL redirects

When enabled by Tizra, a URL path redirect feature has been implemented to support legacy URLs for Tizra-hosted resources. In keeping with its intended application, this issues 301 (permanent) redirects. On most browsers this means that the redirect is cached aggressively, requiring care in testing.

In the Advanced Site Settings tab, this is a JSON Hash property containing regular expression matching strings in Java Regexp format http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html. The substitution value can contain variables and is described here: http://docs.oracle.com/javase/7/docs/api/java/util/regex/Matcher.html#appendReplacement(java.lang.StringBuffer,%20java.lang.String)

The different substitutions will be tried repeatedly (in order), and the system will return an error if a cycle is detected, so as in all cases, we recommend that the simplest pattern be used, and the fewest and the simplest substitutions. Anchoring at the start and/or end of the URL is automatically performed, so as to keep rules from applying in surprising places.

As with all server redirects, caution is in order, as this happens early in request processing, and it is a site setting, not a design parameter that can be staged. It will not be applied to administrative actions that require HTTPs (authentication, Admin UI, or /admin-api), but applies to all other URL paths.

A simple example would be: {"/redirect": "/gimp"}

This would redirect all URLs with the path "/redirect" to a new path. Since the pattern does not include a trailing "/' this means that a URL "/redirect/" would not be rewritten.

An example that would cause a loop error is: {"/redirect": "/gimp", "/gimp": "/gimp"}

Variables can be carried between the match and the result: {"/redirect/([a-z]+)/foo$": "/foo/$1/something" }

So in this case, only URls with a single word sandwiched between /redirect/ and /foo, with nothing else in the url, will be matched.

Once redirection has terminated the URL will be treated as any Tizra URL, which means that if no resource is found, the user will end up on the site home page.