2

D7: I'm going to update an articles path pattern (/articles/[node:uid] → /post/[new tokens]) but I need redirect users from old path to new one using tokens. And I don't know how to do that. I tried using the Redirect module, but it allows set only separate URL for each node; no group redirect patterns are allowed. Also the Rules module doesn't allow to set patterns. How can I achieve this?


The problem partially solves by applying "Update url alias" option in admin/content. I do not find out how to show all selected type nodes at one page without pages, because it is terrible slow applying option page by page.
Anyway, by this way, old aliases still exist, work, and don't redirect to new aliases.

  • do u clearing cache after change pattern? – Yusef Dec 27 '13 at 16:58
  • @zhilevan sure, users can't access old links after updating url pattern – Konstantin Konopko Dec 27 '13 at 17:01
2

You can use the pathauto module to construct your node aliases from tokens (admin/config/search/path/patterns). In addition, there is a setting to tell pathauto to leave the existing alias in place when creating a new one. At admin/config/search/path/settings, you can specify this in the Update action section:

pathauto update action settings

  • Great, thanks! But aliases doesn't updates when I ran Bulk Update after changing path pattern & setting 2nd case in Update action – Konstantin Konopko Dec 27 '13 at 17:11
  • Should I delete all old aliases and then create new? – Konstantin Konopko Dec 27 '13 at 17:12
  • Did you use pathauto to create the initial /articles/[node:nid] aliases? – keithm Dec 27 '13 at 17:17
  • yes, I'm using pathauto – Konstantin Konopko Dec 27 '13 at 17:20
  • 1
    By default the bulk pathauto update will only update paths that don't have a current alias. This is likely a problem for you. In the past, I have temporarily hacked the source of node_pathauto_bulk_update_batch_process() to update nodes even with existing aliases. As far as I recall, the hack is to comment out the line '$query->isNull('ua.source')' but there may be other complications. If you want only nodes of a particular type to update, you will have to add a condition for that. Be sure to work on a backed-up installation. drupal.org/node/236304 has a discussion of other approaches. – keithm Dec 27 '13 at 17:32
0

You can use globalredirect module to redirect from one url to another url.

  • Checks the current URL for an alias and does a 301 redirect to it if it is not being used. Checks the current URL for a trailing slash, removes it if present and repeats check 1 with the new request.
  • Checks if the current URL is the same as the site_frontpage and redirects to the frontpage if there is a match.
  • Checks if the Clean URLs feature is enabled and then checks the current URL is being accessed using the clean method rather than the
    'unclean' method.
  • Checks access to the URL. If the user does not have access to the path, then no redirects are done. This helps avoid exposing private
    aliased node's.
  • Make sure the case of the URL being accessed is the same as the one set by the author/administrator. For example, if you set the alias
    "articles/cake-making" to node/123, then the user can access the
    alias with any combination of case.
  • Most of the above options are configurable in the settings page. In Drupal 5 you can access this after enabling the globalredirect_admin
    module. In Drupal 6, the settings page is bundled into the module.
  • 1
    globalredirect can't redirect by patterns with tokens, that is what I need – Konstantin Konopko Dec 28 '13 at 16:38
  • @konopko, there is two thing. Url alias and redirect. If you want to update alias of all node, then you need to delete previous alias and update to new alias pattern. But if previous alias is saved by any user (like google search) and open the previous url, you can redirect previous url to new url. – Jayendra Kainthola Dec 28 '13 at 16:44
  • actually that is the problem to make group redirection from old aliases to new. there is no tool for that! at least I still don't find that – Konstantin Konopko Dec 28 '13 at 16:49
  • @konopko, I have used global redirect in one of my project. You can set redirect for each url. May be you need to set one by one but its only one time work. – Jayendra Kainthola Dec 28 '13 at 16:56
  • 1
    Sure, but one by one it is bad solution for me, because I have hundreds of nodes, thats why I need use some redirect rule for that. Thanx for consideration) – Konstantin Konopko Dec 28 '13 at 17:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.