Scroll Sites

Advanced (RegEx) Redirects

Advanced redirects can redirect whole groups of pages to help you handle migration scenarios or create the impression of a certain structure.

Scroll Sites lets you create advanced redirects using regular expression (RegEx). RegEx helps you dynamically match any number of URLs without having to create a rule per URL or even knowing what those URLs might all be.

Create and Edit an Advanced Redirect

You can create and manage advanced redirects for your Scroll site from your site’s settings:

  1. From the My Sites screen, click the card that has your site’s name.

  2. From the left sidebar, click Site Settings > Redirects.

  3. Click Advanced redirects. The Advanced redirects dialog opens.

  4. In the Configuration field, enter your redirect(s) in the permitted format (see next section for more details).

  5. Click Save. You are taken back to the site settings where you will now see a list of created redirects.

  6. Click Publish changes or Save changes in the top right of the settings.

Your change will now automatically trigger a new site update (for sites set to live updates) or be applied with your next site update (for sites set to manual updates).

After the redirect is applied, any URL matching your redirect pattern is redirected to the target you specified.

Permitted Values

When using the configuration field in the advanced redirect dialog, you will need to make sure to follow a set format and stick to the permitted values.

To set up a new redirect, always use the following format:

<mode> <source> <target> <type>

Choose from the permitted values in the table below.

Required format:

Mode

Source

Target

Type

Permitted values:

  • regex

  • fallback

  • literal

Relative path of the Scroll site URL with regular expression capture groups.

For example: Can end with /(.*).

  • For internal Scroll site URLs: relative path

  • For external URLs: absolute path starting with //

  • permanent

  • temporary

This page describes regex redirects. literal redirects use a different source format - see Simple (Literal) Redirects. The fallback mode exists for compatibility with sites upgraded from Scroll Viewport and isn't covered here.

Some helpful tips for creating redirects:

  • For protocol-relative links (links that should remain https), you can write //www.example.com as a short-form of https://www.example.com.

  • If multiple regex rules match a path, only the first match is used. Put your most specific rules first.

  • Scroll Sites URLs that are set as a redirect target can contain query parameters, such as in-app help query ?inAppHelp=true. Redirect rules are matched against the path only, so you don't need to do anything to preserve query parameters. The target receives both the parameters from the request and any you hard-coded in the target.

  • Scroll Sites' redirects are case-sensitive.

Example of allowed redirects

regex /my-path/(.*) /new-path/$1 temporary
regex /backbone-issue/(.*)/variant/(.*) /backbone-work-sync/$1/other-variant/$2 permanent

Regular Expressions and Group Substitution

In a regex redirect, the source is a regular expression matched against the request path. For example, /content-source/(.*) will match on all paths starting with /content-source/. It has one group, (.*), which matches any sequence of characters, including an empty one.

The value that the group matches can be reused in the target through group substitution. A substitution starts with a $ followed by the index of the group it references. For example, $1 inserts the value of the first group. $0 is a special case that references the whole match, so the full path of the request.

Redirect patterns use standard Perl-style regular expression syntax, the same as in most programming languages. Character classes, quantifiers, alternation, anchors, and capture groups all work. Patterns are matched in guaranteed linear time, so backtracking-dependent features such as lookarounds and backreferences within the pattern aren't supported.

Example with single group substitution

regex /some-path/(.*) /other-path/$1 permanent

The rule will match on any path starting with /some-path/. It has one group, (.*), which matches any sequence of characters, including an empty one. This results in the following behavior:

  • A user navigates to: /some-path/article?inAppHelp=true

  • Scroll Sites redirects to: /other-path/article?inAppHelp=true

Note that this rule only matches paths that include the slash after /some-path. If you also want to redirect users going directly to /some-path, consider adding an additional literal redirect:

literal /some-path /other-path permanent

Example with multiple group substitutions

regex /source/(.*)/inserted-segment/(.*) /source/$1/other-segment/$2 permanent

The rule will match on any path starting with /source/. Both groups match any sequence of characters, including /.This results in the following behavior:

    • A user navigates to: /source/latest/inserted-segment/article

    • Scroll Sites redirects to: /source/latest/other-segment/article

Escaping Period/Dots in the Redirect

Dots in the source URL of your redirect can be escaped with a \. Add the character right before the period, like this:

regex /content-source/v1\.0/(.+) /documentation/current/$1 permanent

Last updated: