Custom redirects

Xperience provides the IWebPageRedirectManager API, which enables the creation of redirects from custom URL paths to pages. Custom redirects can be useful during upgrades or for creating redirects from pages that were deleted. Existing redirects from deleted pages can also be managed through IWebPageRedirectManager.

Custom redirects are not intended for redirects from existing pages. To create a redirect from an existing page, the page has to be unpublished via the admin UI or the IWebPageManager API. The redirect can be created during the process or added later via the admin UI.

Create or update a custom redirect

To create a custom redirect, use the CreateOrUpdateRedirect method in IWebPageRedirectManager. The parameter webPageUrlPath is used to pass the URL path to redirect from.

If the webPageUrlPath parameter matches a former URL that is not a redirect from a deleted page, or when it matches any URL of a page, the system throws an exception.

Existing URLs managed by the system that don’t fulfill the conditions above are custom redirects or redirects from deleted pages. If the provided path matches such a URL, the target of the redirect from this URL is updated. The system checks only against the URLs included in the content tree-based routing. Otherwise, if the provided URL path doesn’t match any existing URL path in the system, the custom redirect is created with the provided parameters.

See API examples for a code sample of creating a custom redirect.