1 redirect.module redirect_delete_by_path($path)

Delete any redirects associated with a path or any of its sub-paths.

Given a source like 'node/1' this function will delete any redirects that have that specific source or any sources that match 'node/1/%'.


$path: An string with an internal Backdrop path.

Return value

int|FALSE: The constant SAVED_DELETED if redirects were removed. FALSE if no redirects were removed.

Related topics


core/modules/redirect/redirect.module, line 788


function redirect_delete_by_path($path) {
  $query = db_select('redirect');
  $query->addField('redirect', 'rid');
  $query_or = db_or();
  $query_or->condition('source', db_like($path), 'LIKE');
  $query_or->condition('source', db_like($path . '/') . '%', 'LIKE');
  $query_or->condition('redirect', db_like($path), 'LIKE');
  $query_or->condition('redirect', db_like($path . '/') . '%', 'LIKE');
  $rids = $query->execute()->fetchCol();

  if ($rids) {
    return redirect_delete_multiple($rids);

  return FALSE;