Map a URL redirect

Abstract

Use the mapping tool to set up a 301/302 or server transfer redirect.

When you redesign your website or create a new version of an existing web page, it is important to redirect the search traffic from the old page(s) to the new page(s). You can use the mapping tool to set up a 301/302 or server transfer redirect from the original URL to the updated URL.

Important

If you add redirect mapping, redirection starts only if Sitecore cannot find a matching item, just before the user is redirected to the page not found page (HTTP 404).

To add redirect mapping:

  1. In the Content Editor, navigate to your site, click Settings, and then right-click Redirects.

  2. To redirect a map item, click Insert, and Redirect Map.

    To redirect a map item, click Insert, and Redirect Map.

    Tip

    For a better overview, you can group your redirect map items by adding them to a Redirect Map Grouping folder.

  3. Enter a name and click OK.

  4. In the drop-down list, select the type of redirect:

    • Permanent Redirect (HTTP 301) – redirects target resource to a permanently different URL.

    • Temporary Redirect (HTTP 302) - redirects target resource to a temporarily different URL.

    • Server Transfer – helps reduce server requests, keeps the URL the same and is not visible to the client. For example, when you want to transfer the current page request to another .aspx page on the same server or when you want to avoid unnecessary roundtrips to the server.

  5. If you want the redirected URL to match the original URL's query string of the request, select the Shall query string be preserved upon redirect? check box.

  6. Use the mapping section to map between the old (left) and new (right) URL paths. You can use one of the following options. All options are case-insensitive:

    • Direct match – the path of the incoming request is equal to a pattern (patterns must start with /).

    • Regular expression – if the pattern starts with ^ (match only if the following is at the beginning of the line) and ends with $ (match only if the previous is at the end of the line) regular expression matching is used. The target can include tokens ($1, $2, and so on) that will be replaced by corresponding strings from the input. Patterns must include / at the beginning and the end. For example: ^/blogs/blogs-november/$

    • SXA tokens - you can use SXA Tokens to define basic strings, for example, home.com/404. You can also specify more specific elements like language and virtual folder, for example, home.com/$siteLang/$v4/404.

Examples of mapping

The following examples show how to use expressions in the Redirect Map dialog.

Redirect a page with a direct match

Redirect a page with a direct match.

Note

The Include virtual folder option lets you decide whether to include the virtual folder name at the beginning of your target URL.

Redirect the page with a regular expression

For example, the regular expression ^/ab[cd]/$ matches the following URLs:

  • /abc/

  • /abd/

  • /abc

  • /abd

Redirect the page with a regular expression.