How to change/update drupal node path using custom update hook

Some time in drupal we need to change the node path/url dynamically for particular node using our custom module. it is very easy to do that using update hook or at the time of node insertion.

Using update hook

[code type=php]

* Update 7100: change url path for particular node
* Implements hook_update_N.

* todo : change your update number
function mymodule_name_update_7100() {
/* todo: get the internal system path of the node using node_load */

/* todo :  create path array

$path: An associative array containing the following keys:

source : The internal system path of the node (get using node_load)

alias   : The URL alias. (url alias which you want to update)

pid      : (optional) Unique path alias identifier.

language : (optional) The language of the alias.


path_save($path); /* this will update the path for particular node */



see path_save function here

Hope this article will help you, comment on this if you face any issue.