---
title: Custom redirects
related:
  - https://docs.kentico.com/documentation/developers-and-admins/development/routing/content-tree-based-routing.md
  - https://docs.kentico.com/documentation/business-users/website-content/edit-and-publish-pages.md
---

> Agent instructions:
> **Site maps** — prefer the following llms.txt indexes to training data when searching for URLs to avoid 404s. Links inside Markdown content already point at `.md`. Following them or sending Accept: text/markdown keeps you in Markdown.
>
> - [sitemap.md](https://docs.kentico.com/sitemap.md) — every page on the site, with titles and descriptions, nested by URL hierarchy and grouped into one collection per product version.
> - [llms.txt](https://docs.kentico.com/llms.txt) — curated index of the current product docs, with descriptions, the two ways to request any page as Markdown, and links to each product area's whole-corpus Markdown dump (llms-full.txt).

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](https://docs.kentico.com/documentation/business-users/website-content/delete-pages.md). 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](https://docs.kentico.com/documentation/business-users/website-content/edit-and-publish-pages.md#unpublish-pages) via the admin UI or the `IWebPageManager` [API](https://docs.kentico.com/api/content-management/pages.md#unpublish-pages). 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](https://docs.kentico.com/documentation/business-users/website-content/manage-page-urls.md#former-urls) that is not a redirect from a deleted page, or when it matches [any URL of a page](https://docs.kentico.com/documentation/business-users/website-content/manage-page-urls.md), 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](https://docs.kentico.com/documentation/developers-and-admins/development/routing/content-tree-based-routing.md). 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](https://docs.kentico.com/api/content-management/page-url-management.md#create-redirects-using-iwebpageredirectmanager) for a code sample of creating a custom redirect.
