Redirects may be created by end-users to manually redirect from one URL on the site to another one (or to an external URL). For example the path "about" may be redirected to "pages/about-us" after a site redesign. The old URLs should be redirect to the new ones to maintain search engine rankings, existing links, and bookmarks to the old URL.
Redirects are stored in the database in the "redirect" table. Loading and saving of redirects should be done through the Redirect API to ensure modules responding to the modification of redirects also have an opportunity to make adjustments as needed. The Redirect object is used to wrap around all the operations that can be done on redirects. It is recommended that redirects be loaded using one of the existing functions for loading, or if creating a new redirect, created by instantiating a new Redirect object.
See also
File
- core/
modules/ redirect/ redirect.api.php, line 7 - Hooks provided by the Redirect module.
Functions
Name | Location | Description |
---|---|---|
hook_redirect_access |
core/ |
Control access to a redirect. |
hook_redirect_alter |
core/ |
Act on a redirect being redirected. |
hook_redirect_delete |
core/ |
Respond to redirect deletion. |
hook_redirect_insert |
core/ |
Respond to creation of a new redirect. |
hook_redirect_load |
core/ |
Act on redirects being loaded from the database. |
hook_redirect_load_by_source_alter |
core/ |
Alter the list of redirects matching a certain source. |
hook_redirect_prepare |
core/ |
Act on a redirect object about to be shown on the add/edit form. |
hook_redirect_presave |
core/ |
Act on a redirect being inserted or updated. |
hook_redirect_update |
core/ |
Respond to updates to a redirect. |
hook_redirect_validate |
core/ |
Perform redirect validation before a redirect is created or updated. |