URL alias create if not exists

Public
</> CopyGet raw version
php
  1. // For example, if you have a system url "newsletter/24" and want to create "newsletter/2015-May"
  2. $path = [
  3. 'source' => 'newsletter/24',
  4. 'alias' => 'newsletter/2015-May'
  5. ];
  6. $alias = drupal_lookup_path('alias', $path['source']);
  7.  
  8. if (!empty($alias)) {
  9. return;
  10. }
  11. path_save($path);