Skip to content

Instantly share code, notes, and snippets.

@bfodeke
Created June 16, 2017 12:16
Show Gist options
  • Save bfodeke/1cc514d9f8a2375235102ac80e7192d3 to your computer and use it in GitHub Desktop.
Save bfodeke/1cc514d9f8a2375235102ac80e7192d3 to your computer and use it in GitHub Desktop.
Create a redirect to a path using the redirect module.
// Apply redirect from old content to new content.
$old_alias = 'some/old/path';
$new_alias = 'node/' . $node->nid;
$redirect = new stdClass();
redirect_object_prepare($redirect);
$redirect->source = $old_alias;
$redirect->redirect = $new_alias;
redirect_save($redirect);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment