How to change the numbering in duplicate path aliases? All my node paths have a URL alias, provided by Pathauto. The pattern is [node:title]. The generated aliases for nodes with the same title are by default


title,
title-0,
title-1,


etc. I would like to change this numbering into


title-1,
title-2,
title-3,


etc. So, when a node with the title Test is submitted, a URL alias test should be generated. Once a second node with the same title is published, another alias test-1 should be created for the first node and a new alias test-2 should be added for the newly created node.

How can I do that?
pathauto_alias_uniquify(&amp;$alias, $source, $langcode) is the function that does the suffixing to generate uniqueness. It has a hard-coded value that starts at 0.

However, Pathauto evokes a hook, hook_pathauto_is_alias_reserved() when it checks for uniqueness when generating its path alias. If you have a custom module evoke this hook, you can check reject instances of the -0 suffixing and tell pathauto to move onto the next entry.

/**
 * Implements hook_pathauto_is_alias_reserved().
 */
function MYMODULE_pathauto_is_alias_reserved($alias, $source, $langcode) {
  // Return FALSE when the alias ends with '-0'
  $zero_suffix = variable_get('pathauto_separator', '-') . '0';
  return (substr($alias, -strlen($zero_suffix)) == $zero_suffix);
}


This might catch entries that legitimately have "-0" in the path, but I'll leave to the reader to devise a workaround for that scenario.