1 redirect.api.php hook_redirect_load_by_source_alter(array &$redirects, $source, array $context)

Alter the list of redirects matching a certain source.

Parameters

$redirects: An array of redirect objects.

$source: The source request path.

$context: An array with the following key/value pairs:

  • langcode: The language code of the source request.
  • query: An array of the source request query string.

See also

redirect_load_by_source()

Related topics

File

core/modules/redirect/redirect.api.php, line 78
Hooks provided by the Redirect module.

Code

function hook_redirect_load_by_source_alter(array &$redirects, $source, array $context) {
  foreach ($redirects as $rid => $redirect) {
    if ($redirect->source !== $source) {
      // If the redirects to do not exactly match $source (e.g. case
      // insensitive matches), then remove them from the results.
      unset($redirects[$rid]);
    }
  }
}