Tailwind Logo

XM Cloud redirection process

XM Cloud

Published: 2024-07-09

XM Cloud offers two settings for redirects. Redirect Items, which operate on an item-by-item basis, and Redirect Map, which manages URLs related to redirects. These two are introduced in this article.

For more information on settings, the following official pages are helpful.

How redirects work

XM Cloud's sxastarter provides a redirection mechanism as Next.js middleware. And to use this redirection, simply create an item in the CMS.

  • Redirect items - it is possible to place redirect items in the content tree and specify the destination.
  • Redirect map - allows you to determine the URL to jump to by setting a rule that redirects instead of an item.

Base setting

As part of the redirection mechanism, the URL of the site must be included in the Target hostname in the site configuration by default.

Redirects01.png

In this case, we will test the redirect by creating an item called Home/Success as the item to redirect to.

Creating redirects.

Redirect Item

Right-click on an item in the content tree in the content editor and a template for an item called Redirect appears as a candidate.

Redirects02.png

This item is created, this time under Sample. As a redirect destination, the previously prepared Success item is selected.

Redirects03.png

Publish the relevant item in the above form. When reflected,

  • /Sample/RedirectTest path.
  • /Redirect to Success page.

In this way, the redirect can work by setting the URL to jump to for the item in the relevant path. As a site, we have confirmed that it is possible to create an item and redirect as described above, where you have prepared a notice about the end of the page and when it is no longer valid, you will be redirected to that page.

Redirect Map

A redirect map is useful when you want to redirect a site according to some rules. When using this function, it is also possible to control the destination by preparing regular expressions.

Redirect maps can be found under the Redirects folder under Settings on the site, where there is a folder to store redirect maps and their items.

Redirects04.png

The settings include the following items.

  • Redirect type (301, 302 and transfer)
  • Describes the rules for the old path (left column) and the new path (right column)

For example, the above redirection map could be used to ensure that the redirection is implemented even if the item has not been created.

Redirect maps are useful when you want to run redirects for a while when you delete old articles, as they can be processed collectively. By managing the rules as a single redirection map, it is possible to manage the rules in such a way that they can be deleted in the future when they are no longer needed.

Summary

This article provided a brief introduction to setting up redirects and creating items, and the difference between redirect maps and items.

Tags